WS… not so interoperable..

from Udi:
http://feeds.feedburner.com/~r/UdiDahan-TheSoftwareSimplist/~3/127874396/

“…So imagine my surprise when we “Web Service-ized” a bunch of Java components that exposed just that kind of interface, and it didn’t work. After mucking around for almost the whole day, we started returning to basic principles. We started throwing out parameter after parameter, structure after structure, until we were left with something that should have just worked:
string SomeFunction(char c);
But it didn’t.
This was ridiculous. If Web Services couldn’t give me interoperability at this most basic level, I swore that the whole thing must have been a conspiracy. After some ill-mannered googling, I found out that:
The Java char datatype is not supported because of an omission in XML Schema…”

Translating Geek-Speak to Suit-Speak

A colleague and I were talking of the technical debt being incurred on the project we are currently consulting for, when I commented its a bit of a wanky term. CDS quickly reminded me that its a term probably used when a Dev, Architect, consultant is talking to someone in more of a business role and that we have to talk in their terms, i.e. ROI, Debt, Interest, Inflation… i.e “$$$ speak”.
It was a good reminder that in times when you need to emphasise crucial points it probably best to talk in a language the other party will actually understand, and therefore “get” the significance of the problem. It is then up to them to make a more informed business decision from there.

Recurring events and SQL

Working with “Recurring events” is proving to be interesting. I am trying to create a framework that will allow for adding recurring events (such as training times from a given team) with reasonable flexablity, reasonable speed in creating and querying and still reasonably maintainable.
It looks like there will have to be a trade off some where.
I am using the concepts from Fowler’s recurrence essay and extending that. Putting that into a Database pushes me to wanting to use the XML datatype… the more i think about it tho, the less I like it as the querying power would be, well, not so good.
If I use table to map to the temporal expression it could get messy quick too. Either way i am wanting the abiltiy to create db entry for an instance of the recurrence so people can leave note etc for specific occurances…

this is going to be interesting… only post i could find so far has been

http://forums.devx.com/showthread.php?threadid=136165

I may have to step back again and relook at what i’m doing 😉

Common MS SQL “Mistakes” – Part 1

In the last year or so I have moved more in to more consulting and contracting based work which means work working with a larger spread of developers with a an equally wide range of skills and abilities. There have been many generic mistakes I have scene (as well as some great code) but the majority of major mess ups I have seen is by far based around Database and Data Access. This is probably one of the major reasons why so many people are moving to ORM’s, because it removes the responsibility of creating the DA layer and the potential pitfalls that can come with it. This is fine, but it also means that a lot of people are becoming ignorant of the details of these layers. Generally these layers are the very foundations on which the application or applications are built on, I believe the blasé nature in which the technologies are approached is the reason why some run in to such major issues mid project. This late in the scene it is very hard to go back and make schema changes, especially if multiple teams are working off this schema.

I have decided to compile a list of issues that I have run in to in the last year, that I believe are potential short comings of the data related architecture. Often these points by themselves are not huge issues, but when I see one I usually can find another just around the corner.

Hopefully these come as some help to you and your design. Please remember this is coming from a developers perspective, a .Net and MS SQL developer at that, and I, in no way, proclaim myself to be a guru in any regard, however I feel these are basic points should be a general rule of thumb.

Database structure
Normalisation
Normalisation to the 3rd normal is standard. If you don’t know what 3rd normal is then it is a good hint that maybe you may not be the best one to be designing the DB. Sure there are reasons to move away from this rule but it should be just that, a reason, not bad design. Perhaps you may even want to document these reasons so it is clear why.
Nullable Columns
There will always be a need for nullable columns, however when tables start to have a growing number of nullable columns, you should start questioning why. Perhaps these can be moved to a separate table.

Property Tables
If a table is starting to have a lot of columns and many of them are null then you may want to implement a Property table and a PropertyType table. This is relatively clean and easy to set up and if done properly, is a fast way of getting a potentially large albeit often unknown number of properties, and a lot cleaner.

Incorrect Use of the Primary Key
Recently I saw a table that had a multi column primary key over five columns. After spanning more than 2 columns alarm bells go off in my head. In this case this was just bad design. The table only needed one Primary Key with one index on another column. Often this set up I find is good especially when there are unique values such as “Product Codes” that could be the PK but are in a format that does not suit performance (e.g. varchar(1000)). Using a smaller data type for the primary key improves performance. I also generally prefer to use [int] IDENTITY(1,1) as the default primary key for tables. Using large columns as PK’s in my mind is a bit of a no-no. Some times GUID’s are used if there is movement across to other databases. If this is happening then there is probably a properly qualified DBA involved leaving us developers to move back up a layer J

Incorrect Use of the Foreign Key
I have actually seen foreign keys been “used” without the being specifically being set, meaning referential integrity can not be there! Why this was done, god only knows, as it was not documented.

Not Appling Basic Coding Standards
Commenting code is a given. I can’t stand working on projects where Classes, Methods, Properties or Parameter are not obviously named and well commented. Most developers share these views, especially one who have come into projects late. For some reason these principles are ignored when it comes to Database development. Columns get named things like “DscInd” and have no comments associated to them. As far as I am aware there are no real penalties for naming you columns something that is easily understandable. The benefits are however large. People now understanding what is actually being stored! These basic procedures also help spot flaws in any business logic. If the intention of a piece of code is explicitly commented then, if for some reason it is wrong, alarm bells go off a little easier.
Naming conventions are typically applied in managed code but again are often missed in DB Development. I could go on, but you get the general idea. Treat DB dev in the same way you would when it comes to basic procedure such as naming, commenting and using the correct types.

False Economies

As I get older and more experienced in the IT game some basic truths continue to rear theirs head… One I am currently running into is the idea of not doing some standard practice thing because it will “take to long” or “cost too much money” to do.
I have no problem with not doing some because it is too expensive, however when you are building a business critical application for a publicly traded, Tier 1 company, you had better make sure that those things that you are not going to implement don’t bite you in the ass later.
Documentation and Unit testing should not be negotiable. Especially around business object and other lower level layers. If these layers are not working correctly, how can the layer dependent on these be reliable?
One thing I see more often than I like is not putting enough emphasis on DB design. If you are using a very basic OO model and the DB is literally just a persistence layer then I am all for ORMs. If you have complex set based structures, hire a good DB geek that can architect a proper data persistence approach in terms of DB design and helping with Data Access. Often a developer is not the right person to be doing this.
(I think I have already emphasized this enough on this blog)
Another issue is allowing for future changes. Udi Dahan proposed a design principle which I agree with and employee:
For any classes A and B in a system where both A and B have behavior, A should interact with B through an interface.
The interface which separates two concrete classes should be packaged separately from either of those classes
By employing the strategy above, you allow for the ability to have tests to isolate each “layer”. You also then allow for changing of dependency. As long as the new class implements the original interface, how the business logic occurs is irrelevant. This came up specifically this week with regards to the data access layer. Using this strategy we could investigate different options in terms of the DA, such as using the current implementation, a modified version of the current, an ORM or a Generated layer based on the DB schema. If this had been done earlier it would have take lesser than a minute for each class. Not really a huge time loss there.

I dont take all of this as bad things, it is learning from mistakes, whether they be yours or others. The point is we need to learn from them so we can find ways to avoid or fix future encounters.

Currently Playing with Castle stuff and GhostDoc

New (to me) stuff i have been playing with:

As well as the CAB/ SCSF stuff ihave been working on at work, I have been playing with AR & AW at home. They dont really go with my normal views on enterprise level data access, however in my vague attampts to broarden my horizons I have started to dable in their worlds.

Benefits:

  • Easy to read code. As all the DA is under the hood its code creates the illusion(?) of clearer code.
  • Easy to create Business entities and DA, just drag and drop.
  • Seperation of Business entities from UI

All of this can be done with Code smith, however I thought I would look at this as it is another “string to my bow” so to say. I am currently building a smalll web app from it to see how well it work under light load.

I can see these tools beign great for very basic web sites. Get someone who understands the data requirements to build a DB and AR classes then just palm it off to the UI guys as the model aspect of an MVC set up. Would be great from 3 tier app with basic data structure.

Ghost doc… well it just helps with documenting your code. Its very simple but anything that helps with the mundane is a good thing in my book.

Object Builder

Object Builder is a very handy piece of the CAB and software factories, however is sadly not so handy in the real world. I was hoping that it would be a Microsoft implementation of the very useful DI containers that float around like Spring.Net, however I seem to be mistaken. The documentation is sparse and a the PowerPoint I could find wouldn’t run on my current Work PC… hmmm.
After finding blogs like this that seem to be mirroring my own frustrations, I have decided to stick with what I know.
Spring.Net is a fantastic tool that is really, in the scheme of things, bloody easy to use.
Why was I hesitant to use Spring.Net? Firstly we were already using the SCSF, which uses CAB and the OB, so that was obviously my first preference (ie use something already in use!). However as mentioned it implementation fell right into the “taking to long to research and even get started” basket. Secondly, well, some companies are hesitant to use 3rd party tools, especially on critical aspects of business. Having that little “Microsoft” prefix on the assembly tends to give more peace of mind.
However the Spring framework has had such wide testing and I feel that I have given it a pretty good tyre kicking, so I feel happy to use it, hopefully the PM does to.