28 November 2003

MCSD Self-paced Training Kit

I ordered my Self-paced MCSD Training Kit from Computer Manuals yesterday afternoon and it has been delivered to my desk at the lunch break. Four books and a pack of CD/DVD, what a speed!
It sounds uncool to have to use MCSD certificate as the goal/incentive of mastering some exciting hot techies, coz 1) .NET is attractive at its own without using any incentive; 2) there aren't any many industry gurus have been MCSD certified. Certainly, I believe Microsoft will not require their engineers to have MCSD as their objectives.
I think I still need it, given facts that: 1) I haven't had any offsite training course into .NET so far. 2) My boss hasn't booked me into any training course yet. 3) I was working on ASP.NET, Web Services, now Windows Form. I am extremely exhausted and required some heavy recharging. I reckon I need a self-control yet systematic way to absorb new knowledge efficiently. A training kit will not undermine the need to read on MSDN latest update or spying industry guru web blogs. It just provides a well organise document collection to encounter information explosion to a no brainer.
After a quick planning, it works out if I start with 70-316(WinApp) now and spend one and a half hours each day during weekdays (spare time) and fours hours at weekends, I could take the exam on early January 2004.
I shall really book the exam now so leaving no excuse to skip homework for next one month or so.

Life in a Rollercoaster

Yeah, that is right. It is in a rollercoaster.
What a dramatic day today! I have a few interesting things in my bag: a leaving notice; an unsigned contract offered by someone else. I need to decide whether stay or leave before 3 o’clock.

At about 12, my boss gives me a blue envelope containing remuneration package they would like to offer me from next year. It is a big rise in terms of figures, but I reckon it is merely a late arrived justification of what I am worth of.

I got three hours to make my decision. Forget everything else that the bosses promised (not in paper), forget friends and colleagues’ advice. The only thing I need to focus on is: what is the gain/loss by staying?
- Still long commuting time (hope this would change if flexi-time enforced and I can work longer from Monday to Thursday and save Friday to study at home).
- Still playing at the cutting edge stuff.
- Familiar people and bearcats, no need to adapt to a new set of red tapes.
It would be really good by taking Friday off for self-development. I do thing it come to a higher priority even than personal finances side.

It is a long-term relationship; either stay or leave is a critical decision to make. I decide to stay.

However, it is really sad to see some friends/colleagues leaving. Some lost their faith for the future here and thinking of a career change. Or other personal reasons like unsustainable commuting distance-- up to 160 miles a day! I could only wish they good luck and hope we are still friends and will come across some time in the future.

23 November 2003

To use or not to use: Stored Procedures

There is a hot debate between Frans Bouma and Rob Howard on whether using SP in data driven application is a good/bad solution. Here are summaries of the crossfire:

What stung Frans most is the productivity. He admitted 2 months of development had been lost because tried to create a DAL with SP's and a flexible usage of that DAL in C#/VB.NET code. "I failed miserably, because the SPs API is too inflexible."

1. Flexibility, Productivity.
Rob argued using Dynamic SQL (DSQL) introducing high coupling between code and backend while SP provides an abstraction between Business Layer (BL) and DB, hence reduce the coupling.
Frans pointed out that a relational model has always coupling with the application. On the contrary to what Rob said, change to DB schema involves more work: change SPs signature, API that expose SP, caller components that target the API.
My experience coheres to Peter's comment The main bottleneck ... is programmer productivity...Stored procedures are hard to debug, hard to deploy, inflexible.
Code is very difficult to maintain. I have done an intranet ASP.NET application. One-month work, this includes about 110 SPs (24 tables) and corresponding DAL to expose them, all need to be comprehensively tested. And each time when change request comes in, it is an arduous task than a challenging one to dig in the dependencies. This pattern is similar to what Paul Wilson described, but I am the only one on the whole project. I reckon by using DSQL, I can cut down 30-50% of the development time yet boost the morale. (DAL and CRUD SPs are not fun in any sense.)

2. Performance
This could be the major selling point of SP over DSQL on two commobeliefses: 1) SP is pre-complied and execution plan is cached. 2) Cut the client call round trip to DB.
Guess what they are not true or partially not true.
-- In SQL Server (V7, 2000), SP is compiled at execution time and execution plan is cached. So as the DSQL. (SqlServer's Books Online: SQL Stored Procedures)--We are talking parameterized queries not ad hoc SQL statements.
-- In Oracel SP are precompiled. So point taken.
-- Round trip could be an issue. However, we also need to consider BL, DAL server boxes are standing next to DB server behind the proxy. Particularly, we can have a whole batch of T-SQL commands in a single call so to cut the round trip.
My take on is: performance issue need to decide by application profiling. Where if it is impossible to have two solutions side by side, we can stress test application (demo-ware). The result should be able to help us justify other pros and cons.

3. Security
It is now clear that both parameterized queries and SP are immune from injection attack.
Frans suggested using fine granulate role base security as a mean to control data access which is common to both SPs and DSQL. However, Phil Scott felt that for even the smallest set of role base security defined on columns level will be a nightmare. A task-base (rule-base?) is more easy to define and to maintain.
Frans also suggested using view to control security. I think this is a good point. DSQL can still taking benefits of indexed view, so does SP.

22 November 2003

Get the old ford running

A few things need to do to: change battery, check/change oil and coolant, check mechanics and get a new MOT. Talked to a local garage, a full service plus change battery costs around 200 pounds.
I decided to change battery myself, so to save 20 quid. And forget the full service, just get it on road safely will be fine. After all, it is a temporary one.
Brought a new battery from local halfords. For 1993 Ford 1.8 TD, it is HB093-with square terminals. (I didn’t check before going there, so had to go there twice.)
Change battery is dead simple; first release the red terminal (carries 12v power) then the black terminal (earth). Mount in the reverse order: black then red.
However, I have trouble on removing hex blots that fix the battery. There is no enough space to put the wrench in and build the torque. After 30 minutes or so trying with sore arms, I gave up. What I really need is long arm extended socket wrench that can be used virtually from above space. So went to a local home improvement shop and borrow the tool, problem solved in one minutes.
My old mate is shiny and sound now, one turn start: the familiar tractor like engine noise and suffocating fume.

Lesson learnt:
1) Get yourself ready before crack-on; it will only cost more for paying the debt later.
2) Having right tools are important. It saves time, energy and money. In my case, it is mission impossible without the right tool.
3) Use it or lost it. If I could spend one hour a week to get the old car warm up and running, probably I wouldn't need to spend this money now. And it cost nearly nothing to run it one hour a week.

Archaeology sake, invention on tools such like sharp edge stone, wheels are the turning point of human civilisation. So as in software engineering, synchronous business change request and code implementation seemed like a dream before we have Continuous Integration and Test Driven Development tools: CC.NET, NUNIT. We should always ourselves: can we have some tool to do this? (So we can have more time drinking coffee.)

21 November 2003

Car crash follow up (2)

Filled the insurance claim form online. At one bit it asked me to put in 90 characters (NOT words) to describe the importance that has happened to me. I came with something like this: DRIVE CORRECT, PSS UPHILL BRIDGE, HIT SAFE ISLAND B/F RUDABUT, THICK FROG, SIPPER DARK ROAD

Yeah, I said 'frog' where it should be 'fog'. They give me a contact name and number right away. It is Chris Teager. Call Chris 30 minutes later. He opened the claim I just made and confirmed the description I made. Both have a good laugh at 'frog', he asked me was is a big toad. Of course not, just foggy.Then some garage, repairer details. Then he told me repairer would get in contact with me soon, 5 minutes work. Sorted.

However, BT phone booth ate my pound coin without refunding the 50p unused credit. Evil!

Car crash follow up (1)

Walking from garage (near MFI) to home seemed an endless road. It is only then you realise with a car you are travelling at a different dimension. Face freezing in the chilling wind.
Clean all valuables from the car, including the luck lion to take home.
A few things need to sort out into next week, here just a memo to remind myself:
- about the car:
1. Contact the insurer (Today)
2. Produce all legal documents to local police station.(Today)
3. Contact local garage to get the old Ford back on track (This weekend)
4. Alter the insurance to cover the Ford (Next Monday)
5. Buy road tax for Ford (Next Saturday)

-about the job (Omit 3 bullet points hereafter.)

-about the house (Omit 2 bullet points hereafter.)

- Other stuff to happen soon (Omit 2 bullet points hereafter.)

Car crash

I crashed my Mazda 323F (similar to this one) this morning. The car crashed to a safe island right before entering roundabout near Ben's house. It was 6:45, slippery road, and very thick fog. James was with me. We were rushing to meet other guys in car-sharing to go to office...
I can still remember Jim shouted to me 'ROG, WHAT ARE YOU DOING?!...' Then I jumped on the break very hard, then seeing the road mark lamppost (plastic, meter high) banging the windscreen, airbags popped out at this very moment before the car hit and knocked down the signpost (steel) and stopped. It is less than two metres from predestrain lamppost to signpost. The car stay on the safe island though.
We are fine. Air bag hit my face, not very hard, just felt a little bit numb around mouth and nose area. I have glasses on, but it is fine. Acid smoke filled the car. I slowly switched on the hazard lights; switched off the engine but left all indicate light on. I feel fine. Then I release the seat belt and got out.
Derbies were all over the places. Broken glasses, plastics, rubber etc… lamppost flied to 5 meters away, steel post under the cassis- it leaves a deep dent into bonnet before gave itself up. Bumper was gone, radiant are chucked into engine and deformed. Offside were more severely damaged then inner side. Indicators were still on but holder were gone, and so to coolant reservoir.

Call 999 immediately. We then wait at the roadside, other guys have a brief stop and continue to work. Jim was with me to wait for police to come. Apparently they didn’t find us. And after a follow-on call, Mr. Johnson, the policeman turned out. He called Bristol Garage immediately. While waiting, he took a brief testimony with me. Then the rescue lorry turned up and drove us back to Stafford.

20 November 2003

Code Generation Take 2

Visual Studio Home: Part I: Creating Enterprise Templates (Visual Studio Enterprise Tools)
An interesting article. It covers a few hands-on walkthrough on:
1) Static Prototypes. As its name suggested, everything (namespace, class name, solution structure etc) is static and predefined.
2) Enforce some coding practice though the Policy File by Template Description Language (TDL). This topic is not necessarily tied up to prototyping.
3) Subproject Wizards.

MSDN also has a few walkthoughs on creating custom templates.
But not being very useful to what I want to do.

1) Define template project structure: sub-folders, policies, class files. This is achievable with enterprise template as walkthough above.
2) Dynamically create class file (name, contnet - namespace, classname etc). Need to figure out a way to create file name on the fly. say, by using wizard to allow user to specific it.
3) Consume Request/Reply XML doc to create Request/Reply class type and serialisation/de-serialisation.

By getting to point 3, we can say it is full-automatic codeGen.

19 November 2003

A car on the Drive for 9 months

Angela dropped a development change request on my desk for amendment for ISA Statement print, 4 hours in total for change and testing. Timing was based on my initial quote 9 months before. 'Ha, good old days of app components'.
By now I almost forget everything I have done before. Even my Unix account has been 'silently' deprived.
I can't help to think of my old Ford that has been left on the drive for pretty same length of time untouched. To drive it to the nearest superstore takes about 5 minutes. However, to get it started, probably need a new battery and one or two hours checking and warm up.
Need to recover the memory dump...

18 November 2003

Build process, Longhorn...

New solution structure is sorted. Also recovered CruiseControl build process.
Attended Longhorn presentation by Lenn Pryor, (Microsoft's Longhorn Programme Director). Some quotes 'How do we build new generation digital relationship with our customers?' '...There are bugs with current OS...but if we aren't sitting down now and think about it (Longhorn), it will never happen...', 'One codebase software update service'.

Avalon -
XAML: Markup for Windows, build app in simple declarative statements, seperate logic and content:
< Button width='100px'\>OK

WinFS -
'Search today is by text string not relationship'. 'Google is great. It understands relationship, meta data...' 'WinFs is a virtual FS, you still have NTFS. WinFS is built on SQL technology.' It uses local data store to organise doc, spreadsheet, picture, address book... Query based search.

17 November 2003

Some interesting experience people have had on implementing coding standard

Paul Wilson's .NET Blog: "Standard for .NET and VB6 Teams "

New Solution Structure and Political Bogus

Matt haven't got chance to touch the new solution structure last Friday. However, he managed to document our thoughts and decisions onto Cockpit's PatternWiki for later reference.
Now we three get together start to make changes according to the standards. This is great. Eventually, we have something all happy and I can finally put my heart back to the chest. Although it is still not 100% as 'Central .Net PatternWiki' suggested.

Now we have something like this:
File structure:

|- Client
---- Cockpit (proj) -- client app
---- Controls (proj) -- reuse controls

|- Server
---- BusinessLayer (proj) -- cockpit business logics
---- DataLayer (proj) -- data access layer
---- Teps (proj) -- Topend integration, will moved to shared later
-------- Interfaces (folder)
-------- Core (folder)
-------- Components (folder)
-------- Product (folder)

|- CockpitWebServices (proj) -- Web Services
|- Common
---- DataSets (proj) -- common library to both client and server side
|- TestTools (proj) -- test utility tools

Solution structure has Client/Server/Common folder hidden. They are there to physically group projects/assemblies.



Well, it is impossible to have it followed the 'Central PatternWiki' very strictly. Every project (I should say "Solution") is a unique piece. 'Central PatternWiki' gives a loose, high-level abstraction of the practice we have from another ASP.NET project. As in this organisation we are new to .NET development. The central standard needs further elaboration by each satellite project standard that works around it.

It is unfair to accuse central pattern to be 'loose, board and vague' because when it was put in together, there isn't a counter project delivered by another team to verified it. Vice versa, it is dictating to criticise Cockpit project not following the standard.

We make excellent practice a standard and it evolved as improvement made. What we should really look at is whatever that makes more senses, rather than 'we spent million pounds to have it, so live with it.'

Current design came after quite a lot of discussion and debate between Matt and myself and largely follows Microsoft Namespace Naming Guidelines and Coding Techniques and Programming Practices, I would rather say it is a sensible decision.

Sample .NET Coding Standards is also a good sum-up of what Microsoft proposed.

However, there are some unpleasing incidents. D(real name hidden for obvious reason) "happened" to notice what Matt has done for the Cockpit standard this morning and then went to talk to Gary and Matt to find out what is about. Then he came back to me and shagged (don't really want to use this word) me. "We have been spent 9 months and 150 thousand pounds on the pattern, why don't you follow blah blah blah..." Then he sent out an email to Matt, Gary, Phil and cc it to TS and CM. The email is about the Cockpit Patternwiki, mentioning the information there shouldn't really be there and should on the Central Patternwiki and maximise knowledge sharing.

I think there few things here are inappropriate:
1) The budget and expense on another project that brought the central pattern is irrelevant to what Cockpit does. Until the corporate-wise standard being approved and signed off, which then becomes 'rules', there isn't any good reason that we shouldn't make it better.
2) I have been trying to sell central pattern since I joined the Cockpit project from day one. I can only make suggestions, but it is the decision of Cockpit technical lead and architect. In this regard, I would say it is a medium victory that we finally made the solution changes.
3) As one of members that worked on Cockpit team, D should send the email to me as well rather than keeping me out from the conversation.
4) It is technically and politically infeasible for updating Central Pattern without negotiating with the gatekeeper. Otherwise, it will become a graffiti eventually. Or end up with endless debating on 'goods' and 'bads' without having anything delivered. My attitude is 'do it', 'prove it' then show to people.

Now, I should really think about how and when to put the Cockpit Pattern to be with Central Pattern.

15 November 2003

C# Code Generation

The TEPS broker components layer in Cockpit is a simple .NET wrapper that serialises request object to XML and post it over HTTP to legacy middleware and de-serialises the XML reply.
Because the facts that it has very simple functionality; almost no business logics; well defined structure; and massive number of broker components needed to be created for this project, I want to explore how to use Enterprise Templates to automatic the code generation to a maximum extent.
What I want is while in the IDE and have the TEPS project open, developer can right click to bring up a wizard dialog to create a few class files and test cases files, then they automatically add to the existing solution structure.

14 November 2003

I shout if I am not happy

Worked with Matt to sort out the solution structure and name space for Cockpit project. It is now entering iteration 3, week one. I am still unhappy with what Gary has done before.
1) Logic solution structure is not mapping to file structure.
2) File structures are different between build server, local dev. box and source safe.
3) continuous integration fails as if someone changes the binary output dir where build process and/or FXCop point to.
4) namespace pattern is utterly lack of considering on self-documentation.

Followed the discussion with Matt and Gary on Thursday, we started put together a cockpit pattern, coding standard while making changes to the solution.

Gary was not there on Friday, I was pairing with Matt. The experience is great. We suggested and challenged each other. At one point I have been quick and quietly accept his arguments. He asked, 'are you happy with that?' I confirmed 'Yes, I shout if I am not happy.'

Left office at around 2:45, ridiculous early even for a Friday. Some guys in car sharing obviously lost their morale for work. I hate this, something must be done to change it, I can't let car sharing like this to jeopardise my work hence life quality.

Fingers cross Matt will resove the rest so we can move on next Monday.

06 November 2003

Type Fundamentals

When possible, you should use value types instead of reference types because your application's performance will be better. In particular, you should declare a type as a value type if all of the following are true:

  • The type acts like a primitive type.
  • The type doesn't need to inherit from any other type.
  • The type will not have any other types derived from it.
  • Objects of the type are not frequently passed as method arguments since this would cause frequent memory copy operations, hurting performance. The next section on boxing and unboxing will explain this in more detail.
System.ValueType overrides the Equals method so that it returns true if the values of the two objects' instance fields match. In addition, System.ValueType overrides the GetHashCode method so that it produces a hash code value using an algorithm that takes into account the values in the objects' instance fields. When defining your own value types, it is highly recommended that you override and provide explicit implementations for the Equals and GetHashCode methods.

Since you cannot declare a new value type or a new reference type using a value type as a base class, value types should not have virtual functions, cannot be abstract, and are implicitly sealed (a sealed type cannot be used as the base of a new type).

The C# compiler automatically generates boxing and unboxing code. This makes programming easier, but it hides the overhead from the programmer who is concerned with performance.

if a value type doesn't override a virtual method defined by System.ValueType, then this method can only be called on the boxed form of the value type. This is because only the boxed form of the object has a pointer to a virtual method table. Methods defined directly with the value type can be called on boxed and unboxed versions of the value.