Here are six things that many programmers do, but are a waste of time or plain counterproductive.
First, programmers say yes to impossible time schedules. I've done it myself too many times. Stop doing that and take some pride in your work, please.
Second, programmers follow so called "Best Practices". There are no best practices! However there may exist pretty good solutions to certain development challenges. But please make sure you actually have the problem before applying the solution. Remember that no solution is free.
Third, programmers love Inversion of Control. There is too much effort being wasted trying to decouple everything today. It will just make your code harder to read. And however easy it may seem to adjust your code for IoC containers, it is still extra work. Suddenly you cannot use a function you need without making sure that your class is known by and created by the IoC container. Extra work, and for what? Simpler testing? Do you even write tests? You certainly don't need IoC for writing tests.
Fourth, programmers write Service-Oriented code. What happened to Object Orientation? Remember the programming style where the programmer's knowledge is built-into the code itself? The data knows what methods are applicable. Why would you tear that apart and go back to procedural style programming where the data knows nothing of the functions? Waste!
Fifth, programmers use separate build systems. The IDE is there for you to use. It knows how to build your applications. It helps you set everything up, from source code location, library and dependency management, to deployment. Use it, use your IDE! Then use a build server that supports your IDE. Why should I use a separate system for doing all that, where I need to set everything up one more time, without the support of an interactive helpful tool? Ok, there is a reason: The current crop of IDEs are not good enough at dependency management, and the build servers don't support the IDE project formats well enough. Our world is moving to slowly. The tool makers need to speed up improvements.
Sixth, programmers access databases with ORM frameworks. And you need to access the db. You want some help CRUDing your data. Who doesn't. Let's use a great ORM framework. No, no, no! If you want to be able to change things, update your domain classes and keep improving your system you must stop, stop, stop using relational databases. The relational database is a dictator that owns the schema. Your code also wants to own the schema, the classes. The db and the code fight to rule the domain and both lose. That setup aint DRY. The code needs to own the schema/classes. You need to go NoSQL, and you need a db access framework that helps reading persisted data in older formats.
Arne Evertsson
App Director and Software Developer
Sunday, January 10, 2016
Monday, September 22, 2014
Enhanced syntax for switch statements (and if statements)
The switch statement syntax has always bothered me since it introduces two levels of indentation:
switch (value)
{
case 0:
case 1:
doThis();
break;
case 2:
case 3:
doThat();
break;
default:
doSomethingElse();
}
Of course one could reduce the indentation. It would look a bit unusual but it could work:
switch (value) {
case 0:
case 1:
doThis();
break;
case 2:
case 3:
doThat();
break;
default:
doSomethingElse();
}
Let's instead write this with an if statement. It is, arguably, easier to read:
if (value == 0 || value == 1)
doThis();
else if (value == 2 || value == 3)
doThat();
else
doSomethingElse();
Even with curly brackets the if statement kind of looks cleaner than the switch statement:
if (value == 0 || value == 1)
{
doThis();
}
else if (value == 2 || value == 3)
{
doThat();
}
else
{
doSomethingElse();
switch (value)
{
case 0:
case 1:
doThis();
break;
case 2:
case 3:
doThat();
break;
default:
doSomethingElse();
}
Of course one could reduce the indentation. It would look a bit unusual but it could work:
switch (value) {
case 0:
case 1:
doThis();
break;
case 2:
case 3:
doThat();
break;
default:
doSomethingElse();
}
Let's instead write this with an if statement. It is, arguably, easier to read:
if (value == 0 || value == 1)
doThis();
else if (value == 2 || value == 3)
doThat();
else
doSomethingElse();
Even with curly brackets the if statement kind of looks cleaner than the switch statement:
if (value == 0 || value == 1)
{
doThis();
}
else if (value == 2 || value == 3)
{
doThat();
}
else
{
doSomethingElse();
}
But let's think about it for a while. Let's be creative. We could make an enhanced switch statement:
switch (value) case (0, 1)
doThis();
case (2, 3)
doThat();
default:
doSomethingElse();
doThis();
case (2, 3)
doThat();
default:
doSomethingElse();
The enhanced switch statement looks a whole lot like an if statement. How about we enhance the if statement instead:
if (value == 0, 1)
doThis();
else if (2, 3)
doThat();
else
doSomethingElse();
doThis();
else if (2, 3)
doThat();
else
doSomethingElse();
Hey, this looks good! I wonder if it would be possible to write an IntelliJ plugin (or ReSharper plugin) for this kind of syntax enhancement? I guess I gotta find out.
Tuesday, October 29, 2013
First impressions of Visual Studio 2012 by an IntelliJ user
I'm back with Visual Studio which I haven't used since before the first version of .Net. I've been told VS12 is a great IDE, better than Xcode, Eclipse and even IntelliJ. These are my first impressions of "vanilla" Visual Studio, i.e. before installing ReSharper. Let's start with the good stuff.
Note to self: Need to update this to VS13 now that I've installed it.
Note to self: Need to update this to VS13 now that I've installed it.
Nice features of VS12
- VS builds on Visual Basic's ground breaking GUI builder. Delphi also had a great GUI builder (at least back in the days when I used it). Add a button, double-click, write code. This is something to dream about in Xcode.
- The built-in webserver makes it easy to get going with MVC development. (In Java one would typically install Tomcat and then set it up within IntelliJ as an application server).
- Page Inspector is an enhanced browser whose Inspect function will take you directly to the code that created the inspected part of the page.
Great Tools (photo by OZinOH) |
Missing in VS12
- There is no keyboard shortcut for Get Latest Version (Recursive). Unless of course you think pressing the following sequence of keys is an actual shortcut: Alt+V, P, Home, Menu, L.
- And when you manage to get latest, there is no simple path to go the Changeset Details window. Viewing the latest changes is an important operation that should be part of Get Latest Version.
- There is no keyboard shortcut for Compare with previous version. Also you cannot make one yourself since the api call is different for different windows, or even missing.
- Call Hiearchy stops on interface methods. Hey, those get called too you know! R#
- You can't create filterable todo categories. I will often use my own todo tag/token for stuff I need to implement, test or check later. I don't want to mix those todos with those of other team members. R#
- Code Snippets are good, but where's the editor? R#
- There is no Find Usages function. Yes, there is the Find Symbols (Shift+F12) but the result view has a bad layout showing the complete file path on every row. Also Find Symbols doesn't handle usages of the property name that exposes a member variable. R#
- There is no syntax hightlighing for member variables.
Bad and/or Weird Stuff
- The Options window contains hundreds of options but it isn't resizable! It stays small, showing only a few options at a time. VS13
- You can't edit code without stopping execution (Break All). That would seem like logical restriction, but what about adding a comment - not possible! Also, Break All will navigate away from the source file where you wanted to make the edit, and take you the place where execution is taking place. Annoying.
- Many common operations have double-stroke keyboard shortcuts, e.g. Show the solution explorer, Format document, and Show quick info.
- The Find in files result window is badly formatted. For example, it shows the entire JQuery source code if a match is found within it.
- View Call Hierarchy shortcut (Ctrl+K, Ctrl+T) doesn't work at all.
- What is source code doing in the project root folder? It is a really weird thing to mix source files and other project files. Bad design choice.
Conclusion
I can't live without ReSharper.Monday, June 24, 2013
JavaScript global variable declaration tidbits
To make a global variable in JavaScript, type:
var thisHereThing = {};
You could make it even simpler:
thisHereThing = {};
They are the same thing (pretty much).
Let's try a practical example, a namespace for your app:
var TC = TC || {};
Of course you may simplify it to:
TC = TC || {};
Ouch! No, it doesn't work. What is going on here?
What happens is this. The js runtime tries to evaluate the right hand side of the equals sign. It finds a non-existing variable, TC, and gives up. But then, why does it work in the first example that starts with var? It turns out var statements get interpreted before the normal program flow. When the evalution of the right hand side takes place, the TC variable already exists and has an Undefined value.
Even the following piece of code won't throw an exception, even though b is used before its declaration.
var a = b;
var b;
If you wanted to skip the var keyword there still is a way to do that:
TC = window.TC || {};
Global variables are properties of the window object. And properties get created when they are used. So that works as well.
Learning and using JavaScript feels like exploring uncharted territories a lot more than using Java or C# does. Sometimes I like exploring.
var thisHereThing = {};
You could make it even simpler:
thisHereThing = {};
They are the same thing (pretty much).
Let's try a practical example, a namespace for your app:
var TC = TC || {};
Of course you may simplify it to:
TC = TC || {};
Ouch! No, it doesn't work. What is going on here?
What happens is this. The js runtime tries to evaluate the right hand side of the equals sign. It finds a non-existing variable, TC, and gives up. But then, why does it work in the first example that starts with var? It turns out var statements get interpreted before the normal program flow. When the evalution of the right hand side takes place, the TC variable already exists and has an Undefined value.
Even the following piece of code won't throw an exception, even though b is used before its declaration.
var a = b;
var b;
If you wanted to skip the var keyword there still is a way to do that:
TC = window.TC || {};
Global variables are properties of the window object. And properties get created when they are used. So that works as well.
Learning and using JavaScript feels like exploring uncharted territories a lot more than using Java or C# does. Sometimes I like exploring.
Monday, April 22, 2013
Learning from my work notes
As I read through my work notes from last week, I made a few interesting conclusions. As a little background I'm working on integrating a web based system and an access control smartcard system. To bridge the gap between web software and the smartcard reader hardware I'm using an old-style ActiveX component. The component is controlled via Javascript that also communicates with the server.
Thursday Apr 18
Friday Apr 19
But I didn't. Why? Because otherwise I would have ended up with a really low quality application. Software quality is all about user experience. This is conclusion #1:
Week 16 Work Notes
Tuesday Apr 16- Testing ajax calls. Adding error handling when json parsing fails, or if there is a server exception, or an Ajax timeout.
- Starting to work on the "activate card" function in js.
- Adding a progress indicator to show we're in the middle of a ajax and/or cardreader operation.
- Thinking through how to handle the removal of a card when we're in the middle of a transaction.
- Refactoring out all ajax calls into its own js-class.
- Fixing progress indicator (which stackoverflowed in IE8)
- Learning more about ActiveX exception handling when called from js.
Thursday Apr 18
- Now catching and handling all js exception with window.onerror.
- More testing of error and exception handling.
- Adding error handling for when card is removed during transaction.
- Testing and fixing validation of input fields.
- Fixing ajax timeout error handling.
- Thinking through card validity dates, and when a card is to be considered expired or empty.
Friday Apr 19
- Formatting of date and time. Trying to replicate what goes on in Java.
- Coding empty card recognition. Discover that a null end date means the card never expires. Have to change my if statements accordingly.
- The name field from the card is full of \0000. Clean!
- Enable/disable code for input fields is all wrong. Refactoring to methods into one that handles all cases.
32 hours
Summed up, I spent 32 hours working on the following:- UI: Error handling and input validation (Ajax, ActiveX, card data)
- UI: Progress indicator
- UI: Enabling/disabling of input fields depending on state
- UI: Datetime formatting
- Business code: Recognizing empty card put onto reader
Conclusion #1
I spent almost all time dealing with user interaction issues. Did I have to spend so much time with error handling and GUI stuff? I guess not. I could have skipped a lot of the error handling code and testing I wrote. I could have skipped the progress indicator. I could have trusted the user not to click buttons at the wrong moments. Basically I could have saved a lot of time.But I didn't. Why? Because otherwise I would have ended up with a really low quality application. Software quality is all about user experience. This is conclusion #1:
- You need to pay attention to detail and invest a lot of time into UX if you want to build high quality software that makes users productive (and happy?).
Conclusions #2 and #3
What if I were to estimate the time required for the tasks I completed during those four work days? Well, actually all of the tasks are sub tasks to just one user story:- Activate Card: Make it possible to activate a new card and write name, access list, validity dates and amount to it.
- No matter how much work experince you have it is just darn difficult to understand how many small tasks are needed to get a story done.
- Your boss is not going to like it when you add four days to the schedule for just "error handling". And he's going to get the answer he wants.
Friday, January 18, 2013
Whats wrong with IoC and Spring?
My main concern with Spring and the Inversion of Control paradigm is that it encourages the separation of data from operations on the data. In the typical Spring project model classes carry the data and service classes contain operations on that data. So what's wrong with that? It breaks the best feature of Object Oriented software dev, the fact that the data "knows" what operations are available. As an IDE user you just need to press the magical dot which will give you a menu of methods to call. That is great because the knowledge of the programmer that created the class is now built-into the class itself. When the methods are moved into a separate service class the magical dot does not work any more. That is a big deal.
Does it have to be like this with IoC and Spring? I don't know yet. Since it's more or less impossible for an indenpendant Java consultant to avoid projects that uses Spring I'm reading Spring in Action. I've already read quite a bit on IoC but I thought I'd better learn some more practical struff. I will probably get back to this topic in the future.
Does it have to be like this with IoC and Spring? I don't know yet. Since it's more or less impossible for an indenpendant Java consultant to avoid projects that uses Spring I'm reading Spring in Action. I've already read quite a bit on IoC but I thought I'd better learn some more practical struff. I will probably get back to this topic in the future.
Etiketter:
IoC,
Java,
software development,
spring
Tuesday, November 27, 2012
Om konsultmäklare, konsultbolag och konsultsäljare
Jag som konsult är alltid ute efter ett spännande uppdrag där jag kan skapa mycket nytta och glädje för andra människor. När ett behov som matchar min kompetens uppstår vill jag maximera mina chanser att få uppdraget. Drömläget är att jag känner projektledaren och vi har jobbat tillsammans tidigare; saken är redan klar!
Om så inte är fallet behöver jag en bro mellan mig och konsultköparen. Som frilansare är jag fri att välja den säljare ( =eventuellt ett helt team med olika roller) som jag tror mest på. Dom bästa möjligheterna att få uppdraget får jag om säljaren känner både konsultköparen och mig personligen. På så sätt kan det bildas en stark bro av förtroende som kan leda till en affär.
Vanliga konsultbolag har en fördel gentemot mäklare: Säljarna har lättare att bygga en relation till sin konsult. Mäklarens stall är mer flyktigt och kräver en större insats att hålla koll på. Å andra sidan säljer konsultbolaget (nästan) bara sina egna konsulter. Mäklaren däremot har tillgång till alla frilansare och mindre konsultbolag.
Vad gäller relationen mellan säljare och konsult finns det olika grader av kompetensbedömning som mäklaren gör. Det finns mäklare som investerar mycket lite tid att värdera konsulten dom offererar. Kanske funkar deras affärsidé ändå pga en hög volym av potentiella uppdrag och många offereringar? Dessa mäklare hamnar såklart längst ner på listan för mig som konsult. Jag vill säljas som "filmstjärnan" och inte som en "statist". Faktum är att den säljare som mekaniskt matchar uppdragsbeskrivningar med konsultprofiler kan ersättas av.... en app!
Det finns även ett fall då även den bästa konsultsäljaren kan ersättas av en app, och det är när det finns så få tillgängliga konsulter som kan göra jobbet att köparen hinner intervjua allihop själv. Jag tror det finns en stor potential för kompetensrekryteringsmarknaden att effektiveras. För konsultköparnas skull hoppas jag också att dom snart upptäcker den där appen. I mitt tidigare inlägg broderar jag ut lite mer om denna (web-)app som jag där kallar LinkedIn för konsulter.
Om så inte är fallet behöver jag en bro mellan mig och konsultköparen. Som frilansare är jag fri att välja den säljare ( =eventuellt ett helt team med olika roller) som jag tror mest på. Dom bästa möjligheterna att få uppdraget får jag om säljaren känner både konsultköparen och mig personligen. På så sätt kan det bildas en stark bro av förtroende som kan leda till en affär.
Spana in konsultsäljaren längst upp på taket |
Vad gäller relationen mellan säljare och konsult finns det olika grader av kompetensbedömning som mäklaren gör. Det finns mäklare som investerar mycket lite tid att värdera konsulten dom offererar. Kanske funkar deras affärsidé ändå pga en hög volym av potentiella uppdrag och många offereringar? Dessa mäklare hamnar såklart längst ner på listan för mig som konsult. Jag vill säljas som "filmstjärnan" och inte som en "statist". Faktum är att den säljare som mekaniskt matchar uppdragsbeskrivningar med konsultprofiler kan ersättas av.... en app!
Det finns även ett fall då även den bästa konsultsäljaren kan ersättas av en app, och det är när det finns så få tillgängliga konsulter som kan göra jobbet att köparen hinner intervjua allihop själv. Jag tror det finns en stor potential för kompetensrekryteringsmarknaden att effektiveras. För konsultköparnas skull hoppas jag också att dom snart upptäcker den där appen. I mitt tidigare inlägg broderar jag ut lite mer om denna (web-)app som jag där kallar LinkedIn för konsulter.
Subscribe to:
Posts (Atom)
Tags
- scrum (3)
- software development (2)
- #användbarhet #användarvänlighet (1)
- #appcelerator #titanium #review #app #programming #ios #android (1)
- #browser #testing #webdev (1)
- #konsulting #linkedin #konsultmäkleri (1)
- #onlinepublishing #books #safaribooksonline (1)
- #scrum #definitionofdone #testing (1)
- #sj_ab (1)
- #xml #android #GUI #programming (1)
- #xml #android #debugging #usability #programming (1)
- IoC (1)
- Java (1)
- agile (1)
- agilt (1)
- app director (1)
- applikationsregissör (1)
- business opportunity (1)
- conference (1)
- documentation (1)
- iPhone (1)
- java IDE syntax (1)
- konsulting (1)
- konsultmäkleri (1)
- lean (1)
- learning (1)
- mobile internet (1)
- monitoring (1)
- osx (1)
- programmering (1)
- programming (1)
- project management (1)
- projekthantering (1)
- projektledning (1)
- software quality (1)
- spring (1)
- ssh (1)
- systemutveckling (1)
- terminal (1)
- time estimation (1)
- web server (1)
Archive
- January (1)
- September (1)
- October (1)
- June (1)
- April (1)
- January (1)
- November (2)
- October (1)
- September (2)
- May (1)
- April (2)
- March (1)
- February (2)
- January (1)
- November (1)
- September (1)
- August (4)
- May (2)
- April (1)
- January (1)
- September (2)
- March (1)
- September (1)
- August (1)
- November (1)
- October (3)
- June (2)
- November (1)
- October (2)
- January (1)
- December (1)