on business object methods like Consumer.UpdateConsumer() we have several overloads that let you update only a few specific Consumer properties. for example, there’s one overload that takes a CustomerStatusId, another that takes a WhereHeard and a CustomerStatusId, etc. these overloads all call a common, private updateConsumer() function that takes care of the database update, and they pass in the object’s properties for the fields you are not updating, so that the original values are preserved.
however, this means that if you call an overload that takes multiple parameters, any value you pass in as a parameter will be used for the database update. so passing in “null” or empty string will update the database with “null” or empty string for that field, which may not be your intention--
Showing posts with label source code. Show all posts
Showing posts with label source code. Show all posts
Friday, December 5, 2008
Thursday, December 4, 2008
beware maxBufferSize, maxReceivedMessageSize, and maxStringCotentLength when adding service reference in VS2008
when you add a service reference in VS2008, you end up with a entry in your applications app.config file. this element contains binding elements for each service you add.
BEWARE: the default value for three critical attributes, maxBufferSize, maxReceivedMessageSize, and maxStringCotentLength, is set considerably low (64KB). we have hit this problem more than once now with deployed software, and unfortunately the only way to correct it is to adjust these values in app.config and re-distribute the software. so if you think there is even the slightest chance that your service will be returning more than 64KB in data, be sure to adjust these values after you add the service reference.
BEWARE: the default value for three critical attributes, maxBufferSize, maxReceivedMessageSize, and maxStringCotentLength, is set considerably low (64KB). we have hit this problem more than once now with deployed software, and unfortunately the only way to correct it is to adjust these values in app.config and re-distribute the software. so if you think there is even the slightest chance that your service will be returning more than 64KB in data, be sure to adjust these values after you add the service reference.
Thursday, November 6, 2008
Tutor.com Classroom How-To #4: enforcing an MVC-style architecture
These How-To tips are taken from The Tutor.com Classroom: Architecture and techniques using Silverlight, WPF, and the Microsoft .NET Framework.The benefits of MVC-style architecture are numerous: testability, modifiability, simplicity of design, etc., and WPF/Silverlight Xaml “binding” provide an ideal structure to effectively detach the front-end from middle-tier business objects.
You can check out the Silverlight Tutor.com Classroom in "practice" mode, although the real experience is with a live tutor on the other side!
One simple way to enforce MVC-style architecture is to put classes with distinct responsibilities in separate assemblies, and add the minimal set of references only as required by each assembly. This enforces the principle of separation of concerns, since you’ve actually made it impossible for code in one assembly to be concerned with the business of another if it shouldn’t!
Monday, November 3, 2008
Tutor.com Classroom How-To #1: sharing code between Silverliht and WPF applications
These How-To tips are taken from The Tutor.com Classroom: Architecture and techniques using Silverlight, WPF, and the Microsoft .NET Framework.To actually share the code, use compile-time code sharing by choosing “Add As Link” when adding project files, rather than using our source code management’s “Share”. Using the “Add As Link” technique ensures that as changes are made to shared code, successfully building the solution guarantees that the changes are valid across all three applications. Source code management “Share” requires developers to check in their changes, do a “Get Latest Version” on the shared files, rebuild the solution, make any necessary changes, repeat, etc. In the meantime, the build is potentially broken.
You can check out the Silverlight Tutor.com Classroom in "practice" mode, although the real experience is with a live tutor on the other side!
Thursday, November 1, 2007
sourcevault DOES do unicode diffs
not sure how i missed this, but in the Diff window, go to Tools…Options… then in ‘Character Encodings’ section, pick UNICODE. when you refresh the diff, it’s happy--
Tuesday, May 8, 2007
coding standards
having standards makes it much easier to read code you didn’t write, so i do as much as i can to encourage adherence to the list here.
Definitions:
Definitions:
- “UpperCamelCased” = capitalize first letter of each keyword (.NET style); do not use underscores)
- “lowerCamelCased” = captialize first letter of each keyword except the first (java-style); do not user underscores
- “Hungarian Notated” = prefix variable name with indicator of its type (i.e. string sMyString or strMyString)
C#: (in general, follow Microsoft .NET standards)
Functions
- Public functions “UpperCamelCased”
- Private functions “lowerCamelCased”
- Parameters “UpperCamelCased”
Variables
- Module-level variables begin “m_”
- Local function variables either:
o “lowerCamelCased”
o Keywords separated with “_”
o Prefixed with “tmp_”
o “Hungarian Notated”
Enums
- “UpperCamelCased”
- Type name pluralized (i.e. “MyItems”, not “MyItem”)
Constants
- “UPPER_CASE” (all capitalized; keywords separated with “_”)
For example:
public class MyClass
{
public const THIS_IS_MY_CONSTANT = 0;
public enum MyItems
{
None = 0
,SomeItem = 1
,AnotherItem = 2
}
private string m_MyVariable;
public void TellMeEverything(string Input1)
{
bool localVar = false;
bool local_var = false;
bool tmp_LocalVar = false;
bool bLocalVar = false;
}
private void tellYouNothing(string Input1)
{
}
}
Database Tables
- Table names “UpperCamelCased_WithAnyExtras” (capitalize first letter of each key word and use a single “_” character as desired)
- Column names “UpperCamelCased”
- T-SQL keywords “UPPERCASE” (all capitalized)
- T-SQL Datatypes “alllowercase” (do not capitalize any character)
For example:
CREATE TABLE Groups
(
GroupId int
,GroupName varchar(50)
)
Database Sprocs
- Sproc names “UpperCamelCased”
- Separate input parameters or returned columns with comma on line of subsequent parameter or column name
- Clearly separate SELECT/FROM/WHERE or UPDATE/SET/WHERE clauses using carriage returns or tabs
For example:
CREATE PROCEDURE UpdateUser
@UserId int
,@StatusId int
,@UpdateByUserId int
AS
UPDATE Users
SET StatusId = @StatusId
,ChangedBy = @UpdateByUserId
WHERE UserId = @UserId
GO
Subscribe to:
Posts (Atom)
