Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is some clean, elegant, well-designed, well-written, nicely done Delphi code that junior-level Delphi developers should study?

We have a number of junior Delphi developers here in my organization, and as part of the process of teaching them Delphi, I'd like them to look at "clean", well-written, well-engineered Delphi code.

Some criteria I'd be looking for include:

  1. Excellent class structure
  2. Nice use of interfaces
  3. Not overly complex or difficult but complex and difficult enough to be instructive.
  4. Small methods
  5. Code with unit tests.

Generally, I'm looking for code that would make Uncle Bob Martin proud.

I'm familiar with many of the popular Delphi open source projects, but I'd like the suggestions and recommendations of the community.

I'll make this question a community wiki question.

like image 658
Nick Hodges Avatar asked Jul 29 '11 20:07

Nick Hodges


2 Answers

I would recommend you take a really simple program and have the junior developers implement it in Delphi following all those good criteria you listed. You want something that really takes no design on its own (absurdly simple!) The point of the program would be to follow all those best practices. This is especially great if you have a small team that can pair program on it and debate how to best do things. Make sure they do regular code reviews with your senior developers too.

I know that isn't what you are asking for, but I am a strong believer that people learn way more by doing then they do by reading.

For inspiration look at the Enterprise edition of Fizzbuzz. He took an incredibly simple algorithm and over engineered it with all the best practices. (It is written in C#, so you could have your Junior developers re-write it in Delphi).

Then when they are done you can make it open source so everyone can marvel.

like image 145
Jim McKeeth Avatar answered Sep 20 '22 23:09

Jim McKeeth


Not all the code in the repository is equally well designed, but as a source of ideas, and well written Pascal code, there is a lot of greatness inside the Synopse opensource fossil project. Some bits of the repository contain projects that only build in Delphi 7 and are not unicode ready, but the main part I would point you to is the Delphi ORM+SQLite3 framework.

It's not typical Delphi VCL application code, though, it has a very REST architecture driven focus, and the demo uses hand-coded forms in object Pascal, rather than using the traditional delphi DFM based form UI.

I don't know of something that I would recommend, that is all of the things you said above, plus has excellent unit test coverage, plus is suitable for beginner reading, which also sticks enough to Idiomatic Delphi to not be teaching against what I most want to teach Delphi beginners; Stick with the idiomatic solutions, until you're enough of an expert to know when not to use the common Delphi idioms.

like image 27
Warren P Avatar answered Sep 19 '22 23:09

Warren P