My good friend Raj sent me some pic­tures he took from Chi­nese new year 2006, and really brought back some nice mem­o­ries from the days gone by!

As some of you may know, I per­formed on stage for Chi­nese new year in 2006 in Trafal­gar Square, in the mid­dle of the freez­ing cold in Feb! It was def­i­nitely one of the best expe­ri­ences I ever had, the adren­a­lin rush of per­form­ing in front of thou­sands of peo­ple was sim­ply amaz­ing! So, to show you what I’m on about, here’s some pictures ;-)

63_430x330 CNY%20290106%20-%20%2814%29

CNY%20290106%20-%20%2820%29 DSC00032

DSC00033 DSC00036

100_0163030406 (2)

and don’t we all love a poser lol

100_0167

Share

I was hav­ing an email con­ver­sa­tion with a friend on WPF yes­ter­day and he sug­gested putting it into a blog post after I went on and on for a bit (sorry Raj!).

Hav­ing spent some time learn­ing Sil­verlight (which is a sub­set of WPF for the web, Microsoft’s equiv­a­lent of Flash) I have really come to like the new pro­gram­ming model in WPF and how eas­ily it allows you to do things that were sim­ply impos­si­ble to do in Win­Forms (ever tried to put a rounded cor­ner to a rec­tan­gle anyone?).

To those not famil­iar with WPF, it’s pow­ered by DirectX so you get hard­ware accel­er­a­tion and can use fea­tures such as trans­parency, gra­di­ents and trans­for­ma­tions. Its pro­gram­ming model enables clear sep­a­ra­tion of the UI from busi­ness log­ics because you now have to build your UI using a declar­a­tive lan­guage – XAML (Exten­si­ble Appli­ca­tion Markup Language).

The event model has also been revamped and it’s now pos­si­ble to ‘route’ an event so it orig­i­nates from one ele­ment but is raised by another. WPF sup­ports sev­eral types of routed events, but Sil­verlight only allows bub­bled events which cas­cades up the con­tain­ment hier­ar­chy from deeply nested ele­ment to its containers.

Why is Declar­a­tive UI better?

Whilst declar­a­tive UI is some­thing of a shock to the sys­tem to most of us (web devel­op­ers not included!) it actu­ally makes per­fect sense because it helps solve one of the biggest prob­lems in UI devel­op­ment – busi­ness logic embed­ded in UI.

A declar­a­tive UI makes it harder to write busi­ness logic into the UI because you’re writ­ing less code. How­ever, it’s not about sep­a­ra­tion of tiers, but sep­a­ra­tion of con­cerns, so when you find prob­lems there is a smaller blast radius! Which again, all comes down to loose cou­pling — the same thing peo­ple are try­ing to achieve with IoC and Depen­dency Inver­sion from a depen­dency point of view.

So all’s well with WPF and indus­try vet­er­ans are all rav­ing about it (there’s a num­ber of shows on Dot­NetRocks alone which cov­ers WPF and Declar­a­tive UI) so why is there still a dis­tinct lack of real-world apps out there? Besides the odd project on Code­Plex like Fam­ily Show and Scott Hanselman’s BabySmash, I haven’t found too many exam­ples out there (it’s a shame Pho­tol­ogy’s dead.. :-( )

Prob­lems:

I think there are two main rea­sons why a lot of peo­ple are still not adopt­ing WPF, nei­ther has any­thing to do with the tech­nol­ogy itself which is like a fancy new drug which makes you never want to go back! And there are plenty of indus­try sup­port both in terms of third party sup­port (well known UI con­trols pro­duc­ers like teleriks, infrag­is­tics already offer numer­ous UI pack­ages for WPF and Sil­verlight) and back­ing from the indus­try veterans.

1. it’s still fairly young

Hav­ing only made it into the core .Net plat­form since .Net 3.0 (nov 2006) it is still fairly new to most devel­op­ers con­sid­er­ing that most peo­ple are still happy using .Net 2.0 (I know this is def­i­nitely true in the banking/enterprise world!) which equates to:

  • a lack of exist­ing exper­tise in the field, mak­ing it hard for would-be adopters because it adds to the cost of adop­tion in time and expense regard­less of their strat­egy to acquire these exper­tise, i.e. new recruit vs. train­ing exist­ing staffs
  • an addi­tional risk with adopt­ing WPF because you have to first migrate your plat­form to .Net 3.0, which, should be min­i­mal because it’s really just an add-on to the .Net 2.0 frame­work. But then again, “why fix what’s not broken?”

2. it’s only a viable option for new developments

Because WPF intro­duces a com­pletely new set of tech­nolo­gies and a new pro­gram­ming model to boot, it’ll require sig­nif­i­cant time and effort to con­vert an exist­ing UI appli­ca­tion. This means WPF is only worth con­sid­er­ing for new developments.

The future:

As with all things Microsoft, there’s a strong focus on enter­prise users and I’m sure their rep­re­sen­ta­tives would con­tinue to make a push for their part­ners to adopt WPF and dare I say once they decide to jump on board MS would have a prob­lem stop­ping them from com­ing back for more! Yup, WPF is that good!

With the .Net plat­form going strong as ever (men­tioned in 44% of devel­oper jobs posted in the UK in the last 6 months), the uni­ver­sal adop­tion of WPF as the de facto stan­dard for devel­op­ing UI appli­ca­tion should only be a mat­ter of time. Given the risk-adverse nature of large enter­prises (who, given their size and finan­cial mus­cles, have more say on tech­nol­ogy trends than any­one else), it’s no sur­prise to me that WPF has not really caught on, but as more and more enter­prises jump on the WPF band­wagon they’ll in turn increase the size of the tal­ent pool avail­able to oth­ers and really set the ball rolling.

Fur­ther reading:

WindowsClient.Net

Prism: pat­terns & prac­tices Com­pos­ite Appli­ca­tion Guid­ance for WPF and Sil­verlight site

Share

Fol­low­ing my pre­vi­ous post on multi-language (poly­glot) and multi-paradigm (poly-paradigm) devel­op­ment, I thought I’d con­tinue on the same thread for a lit­tle and do some com­par­isons on some of the pop­u­lar types of pro­gram­ming languages.

Def­i­n­i­tion:

An imper­a­tive pro­gram­ming lan­guage such as C# or Java allows you to spec­ify step-by-step how a prob­lem should be solved using a series of state­ments which change a program’s state. It’s impor­tant to remem­ber that whilst Object Ori­ented Pro­gram­ming is how we are all taught to do imper­a­tive pro­gram­ming these days, it’s not the only way – C and other pro­ce­dural lan­guages are also imper­a­tive languages.

A declar­a­tive pro­gram­ming lan­guage on the other hand, is a higher level pro­gram­ming lan­guage which allows you to express what you want with­out spec­i­fy­ing how to get it. SQL is prob­a­bly the most widely used declar­a­tive lan­guage today and in SQL you don’t tell the query ana­lyzer how to go about fetch­ing the data, you just state what data you want to retrieve and it takes care of the rest. It’s also worth noth­ing that

How they compare:

The ben­e­fit of declar­a­tive lan­guage is that it sep­a­rates the process of stat­ing a prob­lem from the process of solv­ing it. It’s essen­tially an exten­sion of design by con­tract where pro­duc­ers of the declar­a­tive input describe what they need and how they need it, allow­ing pro­duc­ers of the declar­a­tive pro­gram to deter­mine the best way to get it.

Approx­i­mat­ing this in an imper­a­tive lan­guage is pos­si­ble because at heart, every­thing is imper­a­tive. The chal­lenge in doing so is that an imper­a­tive pro­gram oper­at­ing on declar­a­tive input must be pre­pared to check pre and post con­di­tions and have a plan to deal with every eventuality!

Declar­a­tive lan­guages allows for greater exten­si­bil­ity, agility and pro­duc­tiv­ity. Think how quickly you can cre­ate a table, input some data and then get the data back in some form or another in SQL and then imag­ine the time and effort it’d require if you were to imple­ment these in C#.

How­ever, as a user of a declar­a­tive lan­guage, you have lim­ited or no con­trol over how your inputs are dealt with and there­fore have no option but to mit­i­gate the impact of any imperfections/bugs in the under­ly­ing lan­guage and rely on the providers of the declar­a­tive lan­guage to address the issues.

Share

Just fin­ished watch­ing an inter­est­ing sem­i­nar video by the guys from Object Men­tor (a con­sul­tant com­pany founded by Robert C Mar­tin, the father of agile devel­op­ment) at:

http://www.infoq.com/presentations/polyglot-polyparadigm-programming

The video is about an hour long and cov­ered a large num­ber of top­ics around using dif­fer­ent lan­guages (poly­glot) and dif­fer­ent pro­gram­ming par­a­digms (poly-paradigm) to sim­plify and speed up the soft­ware devel­op­ment process. The main thing I took away from this was:

“Less code is bet­ter, so less code is more. With less code, all your prob­lems become smaller, be it main­te­nance, test­ing or performance.”

which most devel­op­ers would agree I’m sure, after all, one of the rea­sons we refrac­tor our code is so we end up with less code.

For young devel­op­ers like myself, we have come into soft­ware devel­op­ment in an era dom­i­nated by the object ori­ented par­a­digm and a small hand­ful of main­stream OO lan­guages like C++, C# and Java. So for me at least, it’s refresh­ing to see how other par­a­digms and lan­guages can be used in con­junc­tion with those I’m famil­iar with to achieve:

  • greater pro­duc­tiv­ity from the developers
  • more agile and exten­si­ble solution

Sum­mary:

If you don’t have the time to watch the video (or sim­ply not inter­ested enough to do so!) then hope­fully the list of key points I’ve com­piled together would at least give you some idea what it’s all about:

  • There’s no sil­ver bul­let in soft­ware development
  • OO par­a­digm not always the best solu­tion for the problem
  • Statically-typed lan­guages (C#, C++, Java, etc.) are com­piled for greater speed and effi­ciency at the cost of low­er­ing productivity
  • Dynamically-typed lan­guage (ruby, python, JavaScript, etc.) are inter­preted for greater exten­si­bil­ity, agility and pro­duc­tiv­ity at the cost of low­er­ing run­time per­for­mance
  • Ola Bini’s Three lay­ers – Domain layer (Domain Spe­cific Lan­guages), Dynamic layer (JRuby, etc.) and Sta­ble layer (Java, C#, etc.)
  • Script­ing lan­guages increases pace of development
  • Aspect-oriented pro­gram­ming makes it eas­ier to deal with cross-cutting con­cerns
  • Func­tional pro­gram­ming makes con­cur­rency eas­ier, because:
    • func­tions are side-effect free and stateless
    • noth­ing to syn­chro­nize, so no locks, sem­a­phores, mutexes
  • Func­tional pro­gram­ming is cloud com­put­ing friendly
  • Func­tional lan­guages and DSLs are more declar­a­tive than imperative
  • Scala is cool!
  • Advan­tages of the poly­glot and poly-paradigm approach are:
    • able to use the best tool for a par­tic­u­lar job
    • min­i­mize the amount of code required and keep them closer to the domain
    • bet­ter decou­pling between components
  • Dis­ad­van­tages of this approach are:
    • mul­ti­ple tools, lan­guages, libraries to man­age and learn
    • need to man­age the dif­fer­ent meta­data mod­els and over­head of calls between languages
  • It’s noth­ing new! For exam­ple, web devel­op­ers often have to work in dif­fer­ent par­a­digms and lan­guages on a website
  • Higher end-user expec­ta­tions and tighter sched­ules are dri­ving the pop­u­lar­ity of higher level lan­guages such as func­tional and script­ing languages
  • Devel­op­ers have to deal con­text switch­ing between dif­fer­ent lan­guages, so as the appli­ca­tion grows larger and more com­plex, you have to start par­ti­tion­ing the teams (should be sec­ond nature to those work­ing in the enter­prise world!)

Part­ing thoughts..

As the pre­sen­ter stated sev­eral times through­out, poly­glot and poly-paradigm pro­gram­ming (PPP) has all been done before (despite now being men­tioned with unfa­mil­iar ter­mi­nolo­gies), and I cer­tainly see a lot of famil­iar­ity of it in my line of work where in a typ­i­cal 3-tiered appli­ca­tion you’d have:

  • the data access layer using SQL (rela­tional paradigm)
  • the busi­ness layer writ­ten in C#/Java or other OO languages
  • the UI can be in any num­ber of dif­fer­ent lan­guages or par­a­digms depend­ing on its form (HTML/CSS/Java/C#, etc.)

and numer­ous script­ing lan­guages (Perl, for exam­ple) are also used in var­i­ous places (hell, after all, there are over 5000 appli­ca­tions being actively used within Credit Suisse alone!).

Watch­ing this video has helped me iden­tify with what I already know and put names (poly­glot, poly-paradigm) to famil­iar faces (which is why jar­gon are impor­tant and I keep blog­ging about buzz­words :-P ), watch it, and see if it can help you too.

Fur­ther readings:

Ola Bini’s blog post on writ­ing dif­fer­ent lay­ers of code in dif­fer­ent languages

Share

Def­i­n­i­tion:

A Cross-Cutting Con­cern is a con­cern your appli­ca­tion needs to address that is unre­lated to your application’s prob­lem domain, and ‘cuts across’ other con­cerns. Typ­i­cal exam­ples include:

  • log­ging
  • per­sis­tence
  • secu­rity
  • error han­dling

They are usu­ally dif­fi­cult to decom­pose from the rest of the sys­tem and result in tan­gled code. Address­ing these cross-cutting con­cerns will add a lot of boil­er­plate code into your appli­ca­tion, increas­ing both the size and com­plex­ity of your code.

To ease the pain of deal­ing with cross-cutting con­cerns in our appli­ca­tions, Aspect Ori­ented Pro­gram­ming (AOP) was born and frame­works such as Post­Sharp (which I’ve blogged about already) pro­vides an effec­tive way of intro­duc­ing AOP into .Net applications.

Share