Sunday, July 02, 2006

8 Basic Programming Techniques v3

List of updated items :

(1) I changed the name to “8 Basic Programming Techniques v3”, because nowadays, most, if not all, programming is enterprise computing. By changing its name, it makes it clearer that knowing the syntaxes of some languages, knowing "OO" or “design patterns", do not mean you know how to program.

Yes, I am raising the bar; however, you may also say that I am simply trying to shift the focus. If you do not know the syntax of VB.net (or C#, or Java etc.), but you know those techniques, with real hand-on practices, you are still a good programmer.

As a matter of fact, I changed the whole blog title to “on Programming or Enterprise Computing”.

I removed a lot of comments, but I added “3”, “4”, “5” and “6” marks in the 3-4-5-6 section.

(2) I added loose grouping sections ("backend", "middle-end", and "front-end"), to make it more understandable. Note that the grouping is really a very “loose” one. It is more a kind of "feeling" than anything else. For the “loose reasons”, see the corresponding sections.


(3) The item that directly prompted me to post this new version is:

--- leverage the full power of the “custom class” in the age/context of “SOA”:
Javascript subset C# to Javascript translator. The good news is that I believe I found it in Ajax framework community.


(4) I removed the Pro-Java comments; I guess it is politically incorrect to do that in the age of "close to teenage" of .net. However, I am getting more serious about how to get the best from both C# and VB cultures. I will post them later.

==============================

----------------------backend
----------------------The only thing I can argue about grouping logging with databases, is that for a long time, I always put them together. Perhaps it is because the most important logging is database access logging; perhaps it is because logging is somehow similar to database anyway. Note that the second logging in the middle-end is different from the first logging in the backend. The second one is focusing on the “aspect” aspect of it (the “client-side” of the logging); the first one is on the logging itself (i.e., the “server-side” of the logging).

1. Use log4net, in a simplistic style (avoid fancy stuff)
2. Use MS Ent Lib’s data access block
2’. Use Nhibernate, instead of Ent Lib, when we are in “advanced” situations

----------------------middle-end
3-4-5-6. Use the DynamicProxy in castle framework to centralize remoting(3), transaction handling(4), security(5), and logging(6), at the façade level.

Note: In order to do that, Use programmatic IoC (i.e., centralize all “Factories”); but for most projects, do not use XML style IoC (that is too heavy)

--- to avoid client casting, use factoryMethod
--- use abstrctFactory for switching easily
--- put class name, method name, variable name in the factoryMethod


----------------------front-end
----------------------You may ask: why you put unit testing in the front-end group? Reason: I could put it in the middle-end. However, for a long time in my mind, it has always been in the front-end group, perhaps for two reasons: (a) it is an alternative of the UI code; (b) its very existence depends on the diligence of keeping UI code thin and clean -- remember, I do not believe in unit testing UI code -- that is the next generation stuff; not nowadays everyday practice.

7. The above security and logging can be at property level;
7'. Use the custom class business rule validation technique in CSLA; but via AOP (see above about AOP, but at property level).
7''. Use the “custom class databinding” technique in CSLA; but via AOP (see above about AOP, but at property level).
--- class-to-form using custom event
--- form-to-class (onchange; no exception in set; use rule)

--- tip: listview/read-only-grid read-only: this is good for user anyway;
so, no need of typed collection (note: sorting etc are control's business)
--- tip: update's return object: only get the seq and update the property
do not try to replace the whole object
--- tip: use read-only properties to "borrow" fields for m-m-like
--- tip: inheritance or parent -- pass reader, tx, parent etc.


--- "CSLA with dynamic proxy/aop":
(a) not limiting to 4 (CRUD) methods;
(b) so, no need of special workflow objects,
(c) so, no need for special “criteria” and “exists” classes.

(d) At property level, cleaner property/get/set,
because no CanRead/WriteProperty, PropertyHasChanged calls.

(there is more background info in this blog:
http://www.blogger.com/comment.g?blogID=26752431&postID=115078085354288833 )


--- leverage the full power of the “custom class” in the age/context of “SOA”:
Javascript subset C# to Javascript translator. The good news is that I believe I found it in Ajax framework community.


8. Use Nunit, but only on façade methods

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home