After years of studying and working a programmer who is interested in design gathers rules and tips directing her/him towards better design. I am compiling my own list here. This list is going to grow over time.
Static Methods are often NOT Object Oriented
Static methods don't use internal state of the class in which they are defined, they raise questions like: why methods that don't use fields of the class exist in this class? Do they belong to another class?
Info/DTO classes are often NOT Object Oriented
In a very inaccurate and vague definition, a Class is a combination of methods and fields. A class that doesn't have methods raises questions like: where are functions that work on the fields/properties of this class? (Are the methods scattered throughout the rest of the code instead of being inside the class?) Is this merely a data structure defined mistakenly as 'Class'?
CQS is Object Oriented
Not to be mistaken with CQRS, basically states 'getter's should not change state of the object and 'setter's should not return anything. I am not sure about setter methods but I am darn certain that almost always changing state in getters is a terrible idea.
TDD respects Object Oriented
TDD can result in good design or bad design (test-induced design damage). Moreover, TDD does not guarantee an algorithm or a piece of code is always correct, though it can prove incorrectness of the algorithm. On the other hand, I haven't come across any solution that guarantees 100% correctness of an algorithm, so TDD is not to blame here. On the plus side, TDD often results in early changes to smallest pieces of code which increases code quality over time, moreover, it increases our confidence in refactoring code so IMHO TDD is more helpful than harmful.
Layered often is NOT Object Oriented!
Layered (aka N-Tier) architecture breaks code into separate layers. More often than not these layers are Data, Domain, and UI. The problem is that in layered we have broken code into pieces/layers that are decided based on technology (instead of bounded contexts for example). Fo example, this design makes it difficult to switch from old-style databases in the future when databases are no longer in the form they are today.
DRY might be NOT SO Object Oriented!
Imagine a service that is sending some dto to a client. Client has some deserialization in place. It is very compelling to send the same deserialized object to upper layers but it is worth reconsidering! A WET mapping is a better idea! In upper layers we need domain logic inside classes not just data structures so fields/properties of the upper layer classes will most certainly not fully match those of the deserialized object. I'd rather be wet with a few similarly named fields than have a combination of the fields forced by the deserialization process and those forced by the domain, inside one class!
Windows 10 is stable now. Upgraded from Windows 7 to 10 (for like 4th time! but this time everything went) very smoothly. The OS is now MUCH more stable than it used to be a few months ago. Andromeda and Polaris show that finally MS has a clear direction (bold goals which I love, admirable Microsoft, respect!). Watched this video the other day:
I cannot wait to work with Asp.net core and web assemblies, specifically Blazor to build good software products.
I have been studying Object Oriented design principles, practices, and patterns for a long time. I have used many of them in my code and now that I look back I see common patterns in everything even these principles!
I believe most of what programmers learn is algorithms, written with different intentions, of course. Back when I started learning algorithms, the goal was to have highest possible performance; remember how O(log n) was much better than O(n)?!
But, reading design books I learned in real life what matters the most is decreasing costs. Main source of cost seems to be that caused by CHANGE. So, we are taught new set of algorithms called OO patterns. These algorithms are not created with the aim of high performance but instead they are to make code readable, maintainable, and changeable in long run.
When it comes to scalability we learn new ways of doing the same thing, we learn about distributed systems. The interesting part is that higher performance is not of much importance here either because no matter how high performant a code is eventually users might outnumber it! So what matters is to be able to change scale the system by adding hardware whenever required. This requires new techniques and familiarity with new science and tools.
So, I believe what we are learning all the time is different algorithms each tailored to a specific goal, to solve a specific problem. Much as we write an algorithm to solve a math problem we have broader algorithms to solve scalability, maintainability, performance, globalization, and other problems software deals with. Although they are given different names, essentially they are only different algorithms.
I find myself a man who looks for patterns that require certain algorithms to change them into more demanding patterns!
If you have worked with layered architecture and an ORM for a while you probably have a set of repository classes with some GetSomething methods to return records (probably mapped to objects) from database. To prevent loading all objects you probably have some conditional statements that are applied to query before linq executes them like this:
public SomeObjectList RepoMethod(bool includeRelatedRecordSet1)
vr query = context.AllObjects.Where(condition);
if (includeRelatedRecordSet1) query = query.Include(q => q.RelatedRecordSet1);
The problem is that as time passes and applications get more and more complex the list of parameters increases and we endue recreating LINQ albeit in an ugly way!
We don't want to return query and execute it + map results using LINQ outside repository for design reasons, we don't want to return all mapped records and then execute LINQ on objects outside the repository for performance reasons. What should we do? Should we accept linq to object queries as input parameter (lambda) and map these queries to ORM queries? Seems like too much work. Looking for a solution...
A class that is somewhat dumber than Linq but more flexible than Repository produces better results. For example this is the code using the class:
var friends =
Microsoft already has the best programming languages in the world; C# and F#. They have the best IDE too (Once installed and ran though! Installer of the latest version (14 AKA 2015) really sucks and also it is becoming too slow to start but once started, and especially if Resharper is installed too, it cannot be beaten.)
However, all of these might become obsolete in no time. IF desktop programming becomes obsolete, these tools won't be of much use in such a future either.
Microsoft could create the best cross-platform solution for developing mobile apps and it's not the way Xamarin has done it. Xamarin has made it way too complex. The genius designer of "CodeName One" has done it though, IMO.
Regardless of the idea that Web will rule the future (advocated of that idea believe it will happen the same way web ate large portion of native desktop app market-share), for native app development I see no better solution than CodeName One.
CodeName One has done the difficult part of the job and actually has done it in a very efficient way! The GUI is rendered using OpenGL. That means creating UI has become easy because we no longer deal with two or more distinct native platforms and especially we no longer deal with crap set of apis that Google has created for Android. We can focus on one easy to use framework. Customization is possible and sometimes not that difficult either.
Microsoft could use this idea and empower C# developers this way. They could win developers developers developers again!
One of my fantasies has been to read a mysterious lyric inside of which there are lines referring to other songs (probably by mentioning their name or a line of their lyrics).
I know advertisement experts would misuse that and it will eventually be a "music as a service" thing in which a lyric earns money by introducing songs of others (others who pay to be introduced of course!) inside songs of the most famous ones but still the initial lyric would be extremely fun. Figuring out what is the hidden lyric would be kinda of fun too.
This means connecting lyrics, and in a way, songs to each other!
Trying to create a little project with Asp.Net 5 preview I noticed a project I have moved into another virtual machine can't run in IIS Express. The problem turned out to be a path to the old directory somewhere stored inside a directory called ".vs". Deleting the directory and reopening the project fixed everything.
Just delete the ".vs" directory in case you moved your solution to another drive. VS can build it again.
After over 20 years of being a user of Microsoft Windows OS and related products and over 10 years of programming for it professionally, I decided to check out latest status of Linux again. I did and it is frightening!
Last time I tried Linux was when I was still studying in college. I was interested in exploring all options (I still am!) and then choosing (and sticking to) the best one (I no longer do though!) so I played with Redhat from version 6 to 9 and then Fedora. I also tried a few other distros. My experiments showed me that Linux is in general way too fat for my desktop machine, besides, I had to fight with they system to get it to work the way I wanted it, in comparison Windows was flying like a free bird (!) and drivers were easy to install. Moreover, Windows had applications with MUCH higher quality. (apart from a consistent, fast, and responsive GUI, I recall the pleasant experience of JetAudio, sharp and vivid colours of PowerDVD, excellent games when I was a regular user and then quality of Visual Studio IDE along with a comprehensive offline version of MSDN.) I chose Microsoft because they had the best quality software.
Fast forward 11 years and same is the reason to move to Linux. Ubuntu just worked even before installing! (Live CD) In fact I was listening to a great song while installing it on my main machine! There were zero issues with drivers. (Actually, I didn't install anything!) and best of all, nearly all the applications I have been using are open source and have a version on Linux and to install them, I don't need to head to tens of websites; there's a repository much like Google Play app store but for desktop. GUI is not as good as Windows but after experiencing Windows 10, I can say it's even more consistent than Windows now! And, FORTUNATELY for me, everything is not flat here!
The only missing things are VisualStudio and Photoshop, however, there's VirtualBox in the app repository.
It's hard to believe an OS with this quality is free. I used to laugh at Apple fans because they have been spending ridiculous amounts of money over cr@ppy products, yet wasn't able to see my own bias towards Microsoft. Don't get me wrong, Microsoft was the best software company in the world. (In fact I have always dreamed of working at Microsoft, who hasn't right?!) But unfortunately they have lost their position and worse is that they don't seem to decide to go back.
Microsoft has turned their back to some of the best quality and really cool products they have created (like .Net platform and C# and F# languages) in favour of the closed system of Universal apps and an ugly basic interface they call 'minimalistic design', 'modern', 'metro', etc. It's not art. Not every ugly thing someone famous but illiterate has in mind is art. I don't understand why some people think a futuristic GUI is made of flat lines and rectangles? I believe a futuristic GUI is the one that has been evolved over time the way nature works, evolution rather than revolution. Moreover, I am in favour of science over ideology.
But that unfortunately is not all the story. Beneath the GUI, Linux is actually working better than Windows. For one thing, my hard disk LED is now almost always switched off while in Windows it was almost always on. I don't understand why applications and the OS uses hard disk that bad. I know that Linux file system doesn't need de-fragmentation, but it's not like Windows is de-fragmenting all the time, is it? Moreover, how can Linux run this fast? I mean it was ready to work in a fraction of the time Windows 8.1 needs to load to desktop (FAKE load by the way because after a few years past the installation Windows wasn't responsive to even keyboard interrupts minutes after a boot).
I couldn't imagine a day in which Linux become the faster OS with prettier GUI yet that day has arrived.
BTW, if you are a programmer and have a look at the Linux stack, they almost already have "write once - run everywhere"; Python has Kivy, Qt supports Android and iOS, RoboVM (with insanely high performance on Android) does that using Java, and the list continues.
I will certainly continue using Visual Studio because I really love C# and to an extent I like Web Api and MVC (Apart from Identity, it sucks! One of the worst releases from Microsoft) but for most of my tasks I will be using Ubuntu instead of Windows 10. I will sure miss Windows. I wish they get back where they used to be, after all I used to love the company and their products.
Why should we inject dependencies?
Why shouldn't we hide them?!
What is dependency anyway?
Almost everywhere people use IOC containers and DI frameworks to inject dependencies to classes, often by adding all "dependencies" to a class's constructors as parameters. Apparently the rule is that any class we use inside another class is dependency and shall not be instantiated internally but to be provided as constructor parameter (or a property of that class).
The funny thing is that classes themselves have been created with the intention of hiding their states. In fact libraries and modules in programming languages allow us to no longer think about internals of services but to be users of those services. However, when it comes to class composition these days we shouldn't hide ANYTHING!
There's a problem that's been overlooked, IMO, and it's the amount of complexity we accept by introducing these (often) useless flexibilities.
First of all passing dependencies as parameters makes all the layers that need to pass these dependencies to lower layers more coupled to those dependencies of lower level classes! I don't understand how design legends justify this coupling really!
Then comes all sort of solutions for a problem we created ourselves! One common solution is using factories, then when there are a lot of them, use factories of factories. What a mess!
This much complexity is not worth it, IMO.
Unfortunately dependency injection is not the only commandment sent to poor developers by gods of design. Think about it: when was the last time you decided to replace you Domain layer in an app entirely?! When was the last time you could afford it? When was the last time you really went ahead and did that? I am not saying nobody needs that, I'm just saying do we have any valid number/statistics that tells us the real value of the price we pay? On how many project this has been useful and on how many has it been useless extra cost?
Don't get me wrong, I really like layered design but not because of Dependency Inversion principle that allows us create decoupled changeable layers, but because it helps my mind to deal with only one topic inside each layer. It kinda helps me focus on the task at hand.
Dependency injection, however, is not something I can always like. Sometimes I like to hide classes I use inside another class. I prefer no one on higher levels even know how a class is doing what it does!
Playing around with Asp.Net 5 today. It's still not ready and not worth the time that's going to be wasted fighting with the framework. I spent like two hours getting an upgrade to beta 5 to work but was not successful. Apparently there was an issue with DNX versions.
It's fine to have bugs at this point but what's not cool is the fact that for a simple project we have to edit 2 files as well as the project properties to set the target .Net framework version, moreover, all the three version must match. (Even though in my case VS couldn't find a beta5 of Core framework).
IMO, it's a serious design issue that the version is going to be read from 3 sources.
Decided to install VS 2015 RC in a virtual machine, OS has to be at least Win 8.1. Win 8.1 must have update 1, BTW. While trying to install Windows8.1-KB2919355-x64 I got an error message indicating nothing!
"This update is not applicable to your computer"
Event viewer didn't provide any clue either. It turned out that this KB is dependent to another KB: Windows8.1-KB2919442-x64. After installing the dependency it all went fine.
Note to self: all application errors must guide user what to do. General errors aren't helpful.
I wish there were 5 buttons instead of three for every window in Windows; Close, Restore, Minimize, Minimize to Tray, z-index button or control (keep a window in front or bring it to the front, etc.).
Moreover, I wish there was a way to reopen the window I just mistakenly closed, cause let's face it, the Taskbar is kinda similar to Tab control (BTW, IMHO, Firefox has created the best solution for opening many of them simultaneously, restoring them (Ctrl+Shift+T), etc.)
In fact, I have recently used file explorer in Ubuntu and it's cool to have a tab control for that too per every open window. Cool ideas, not Modern style perhaps but very usable.
Services need to be more aware of each other. In my mobile, for example, I have a list of SMS messages, a list of contacts, multiple apps for email, socialization, etc. Can I find answer to this question while I have all related data: "With which contact of mine am I communicating the most?"? No!
Data of all these apps are separated and these apps won't communicate; even in unified platforms like MS Windows. I believe if our apps could communicate more effectively, we could have a much richer experience. Imagine I could ask my phone to go through all the history I've had with some contact person in all my apps, in any form, and search content of all of them for a specific phrase.
Imagine a statistics app could communicate with all these other apps and count for me how long have I spent with each friend of mine or what are we often talking about, i.e. what are our interests or cool stuff like that.
Imagine an app that could tell me what am I doing with my life by showing me a pie chart of the amount of time I spent on each of my digital activities.
Imagine what a fully connected software world could provide humans...
Apparently $.connection.MyHub was null. $.connection was all good, but the hub wasn't there; generated Hubs.js did not contain any proxies, but why?
I tried almost everything I could find on-line, nothing worked. I enabled logging and saw this in my browser Console:
"Failed to load resource: the server responded with a status of 500 (Internal Server Error)"
Default .Net configuration framework is not good, IMO, because it pushes us to have one file per project, but then when it comes to libraries we aren't allowed to have one per library because libraries won't load any configuration file.
The result is often mess in most projects I have faced. Some settings are duplicated in multiple projects, some go a long way (through a set of layers and classes) to reach their destination. Moreover, updating settings file (let's say the app has a new feature that requires adding new items to user settings file) is a big trouble (I have even spotted strange uncertain behaviors); besides, it can be located in multiple directories which makes updating the file manually a nightmare.
I took a different approach in two projects recently. I created one "Settings" project for my solution and forbid adding any "settings" file to any individual project. Any other project that needed to load/save settings had to add a reference to this new "Setting" project.
To make it easier to access settings I created kind of a Service Locator in this project called "SettingsMan" which can load any of the requested settings like this:
I also used Nini to have an "ini" as my setting file. The end result is much better structured and cleaner code.
Enjoying from reading design books and many online (and even offline in books) debates, I was wondering which of the following is a better design?
if ((new Username("AUsername")).IsValid())...
if ((new UsernameValidator).IsValid("AUsername"))...
if ((new UsernameValidator("AUsername")).IsValid())...
Or this one:
if ((new SupportedCountries).Contains("Canada"))...
if (Countries.Where(x=>string.IsEqual(x.Name, "Canada")).IsSupported)...
As far as opinions are the driving force in this field we wouldn't see a real improvement. I believe, design, more than a new book or article, requires real scientific research.
I have studied MS Sync framework a bit and I think I have an idea of a better solution.
Sync frameworks that I know of, so far, work on data. They are coupled either with client side databases (like SQLite on mobile), server side databases, or even both. Moreover, they add fields to our database tables. That's error prone, costly and doesn't allow any easy or cheap way of implementing transactions.
I think a better approach is possible; instead of syncing 'data', we can sync 'events'. Using 'event sourcing' pattern, applications can keep track of changes they make to data. If these events are sent to server instead of data, server can recreate database instead of replicating client side data. No longer has server database needed to be bound to a syncing technology, heck it doesn't even need to know what sort of store each client is using. Server can optimize events before applying them on database or check them for possible conflicts. In case of a real conflict, the set of events can easily be rolled back so it gives a cheaper transaction implementation possibility. Furthermore, no table will need to be touched in order to create such a synchronization mechanism.
Just some ideas and a very basic raw untested theory, need to research more on the subject. As soon as I find a bit of free time, I’ll try implementing this. If it works, it might actually become big, IMO.
Type in a search engine REST VS. and the first result is 'SOAP'! Then there are lengthy blog entries explaining the difference. This makes me close my eyes for some seconds and dream about a world in which Internet could be cleaned up of all sorts of useless words, so real pros voices could be heard.
Nevertheless, here's my 2 cents on the subject:
REST(Representational state transfer) is an architectural style. On the other hand, SOAP (Simple Object Access Protocol) is a protocol. So it is really comparing apples and oranges.
The thing is, for writing and consuming services, we can follow guidelines/restrictions of REST, which by the way says nothing about the protocol (No, it doesn't need to be over http) and thus create a RESTful (why should it be written in such an ugly way, I don't know!) service or use other approaches. One of the other most popular approaches is message based SOAP protocol, often implemented by following guidelines of SOA(Service-oriented architecture).
If you dig deeper, you'll notice that in order to implement SOA, lots of patterns and standards are used. There are many SOA books available if you are interested to understand it better, or if you enjoy design patterns like I do, it's worth to take one and read a few pages to see what patterns are evolved over time to shape SOA.
As a programmer who invested on Microsoft technologies for the past ten years, what I know as an implementation of SOAP for communication is WCF and the one using REST style is called WebAPI.
I found one of the properties of REST to contradict some restrictions. The property is "Performance" and restrictions are "Self-descriptive messages" and "Manipulation of resources through these representations" which basically say that each message and also each piece of data must be self explanatory so without the need of any metadata or contract, client can manipulate data or access related information. Just imagine how much relationship/manipulation (I'm not talking about known URLS for manipulation like GET/PUT/DELETE) data each record should hold. How then it will have high performance?
Nevertheless, most web based RESTful services aren't RESTful based on those restrictions and prefer performance over those restrictions when it comes to implementation.
<DIV> is a nightmare for many website programmers. Compared to that, WPF layout tools ROCK!
I think it might be because they are tailored.
While <DIV> is the one magical layout tool which is going to do everything, its behavior can be interpreted differently (and it actually does by different browsers), WPF comes with a set of tailored tools (StackPanel, Grid, LayoutPanel, etc.), each of which does one simple thing that cannot easily be interpreted otherwise.
Interestingly, same is happening in hardware world. All-in-one desktop PCs are being threatened (not by tablets alone but) by the sheer volume of different devices, each of which are tailored to do one thing and doing it better than PC does.
Planning to move to Germany, looking for a job there! Looking for a Windows desktop programmer? I look forward to hearing from you!
If I want to name main issues with Win 8, on desktop, I'd say:
1. Lost control
This was the main issue I had with Metro style apps. Not knowing where to expect to click/right-click/touch for magic to happen. Even default applications did NOT use exactly same layout and if they did, they were so frighteningly incomplete in number of features. I couldn't adjust simple things like detailed quality settings of my Webcam!
Not having old multi-tasking features, made my daily works slower. It felt like it was forcefully limiting me.
2. Unorganized, Untidy and Chaos.
Some items on the right, some on the left. Path to commonly used settings are going further and further away. (Try changing IPv4 settings in XP, then try it on Win 8!).
Newly installed applications appeared all over the start screen and it was impossible to organize them the way I wanted.
Some windows settings would open in desktop, some seemed to be accessible only via Metro.
3. Look and feel
It felt incomplete, like designs of a new graduate graphic student while Windows 7 looked really mature.
I am back, and unlike my journey back from Vista to XP, now I don't feel in an outdated world, but a different world, a better one to be honest, one with more freedom!
Couldn't resist again! A few weeks ago I installed 8.1 + ClassicShell. It's like 7, stable and everything, only faster. I like this OS on desktop, still don't like Metro GUI. Hope next Build event brings good news to all of us.
Planning to move to Germany, looking for a job there! Looking for a Windows desktop programmer? I look forward to hearing from you!
Introduced in 1999, Web 2.0 was a set of new features, namely dynamic vs. static pages.
For me, as a user, it was the time when people started providing content. There are two main problems with this approach which I experienced while being a member of Facebook, or reading comments under books of Amazon.com.
1. Inaccurate, sometimes completely wrong and very harmful data:
Everybody talks, mainly based on their ideas, and ideas are often result of over generalization of past experiences in our own lives or other reliable or unreliable sources.
Just recently I began a small research in my own profession, programming and noticed many issues in Wikipedia articles, in comparison to reliable sources.
Just read reviews underneath Amazon books, I find some reviews that belong to a completely different book, or reviews that seem to be written after spending 10 minutes with a book.
2. People work for free for Web 2.0!
After I left addiction to Facebook, I noticed that I was wasting invaluable hours of life doing something that wasn't actually worth it! I don't know how many people will give up, stop and think about how they are living their lives but if the number increases, Web 2.0 will die eventually.
A good question to ask would be, is it worth spending so much time, producing a content that many times isn't worth and sometimes are even harmful?! A side effect of this move is that the Internet is filled with huge volume of useless content that even separating it from useful ones is becoming an issue and many apps are being written to automatically sensor useless data!
To have a successful future, I believe data shall become reliable.
I believe it is best that only experts produce data, but on the other hand, freedom of speech shall be preserved. So I was thinking that maybe in the future, applications can produce metadata around users data. Metadata that will help readers to weigh value of the published data they face everyday. Metadata that is gathered as part of daily lives of users. Data in this scenario isn't solely result of a users work, but a result of a service given to a user, during which users opinion and monitored actions data are gathered.
For instance, imagine a book store website that only allows comments via an e-book reader application. Very restricting, but one can say, comments on this website must be much more reliable. (Quantity vs. quality)
An e-reader application that will monitor readers actions (with permission of course) and when a reader asks to delete a book, asks why? This app, keeps track of books a reader has read and can be viewed by the user as a database to refer to, next time he wants to pick up a book from same author for instance(giving service to user), but also, it can ask user to share her/his experience (producing content).
This experience becomes a review of the book and also metadatas like:
* How many hours this reviewer spent with the book?
* How many pages she/he read?
* How many minutes she/he spent on each page?
* What is the total number of books this user has read and on which subjects?
It can be completely anonymous, by omitting real readers identity, and at the same time creating useful quality content to guide future buyers of the product (book in this example)
I believe if the service of the application is good enough, users will install it voluntarily, just as many users are now installing Android apps that ask permission to access a lot of private stuff.
My WiFi router died a few days ago, before I buy a new one, I needed internet on my android phone, there seemed to be a solution, Microsoft Virtual WiFi; unreliable online information indicate that some Wireless LAN interface manufacturers have added a feature to their boards that allow the normally receiver board act as a transmitters too. Sounds interesting! Let's try it!
There's like a million blog entries and tens of applications on how to create and run it.
Note: I actually had to go to Device Manager, refresh list of Network adapters and enable 'Microsoft Hosted Network Virtual Adapter' before these commands could work correctly.
and then share my pc internet with the newly added virtual adapter (LAN adapter Properties>Sharing>VirtualWiFi).
After I went through all the steps, I faced another problem:
Android device could see the new Wireless network, but couldn't get an ip from it. 'ip config /all' reported DHCP to be disabled on my VirtualWiFi adapter. Why? I have no idea, after all network isn't my specialty. I decided to go the easy way of assigning IPs manually.
At first it seemed impossible in Android ICS! After half a day I figured, it is possible!
- First, on my LG phone, it can only be assigned upon first connection to a WiFi.
- Second, even though 'Static IP' fields are grayed out and already filled with some numbers that can't be deleted, it's just an android GUI bad decision, I accidentally typed a new set of digits, it worked!! It wasn't disabled! I believed it's disabled so hard that I didn't even try to enter digits. Kinda frightening how I live based on prior assumptions though!
So here's my static IP assignments:
DSL Router (DHCP but I actually am not using it anymore!):
My Virtual WiFi adapter:
NO DEFAULT GATEWAY
My Android device:
Planning to move to Germany, looking for a job there! Looking for a Windows desktop programmer? I look forward to hearing from you!
Last Visit: 9-Jul-20 15:30 Last Update: 9-Jul-20 15:30