usable in any place a human can be used

Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

20091228

modeling

[caption id="attachment_479" align="alignright" width="225" caption="Just like this, only less beautiful women and more boring data"]america's next top model[/caption]

When solving a problem the most difficult part should almost never be the implementation. Implementing a solution should be fairly straightforward from the solution itself, if it is not, then your solution is incomplete. That doesn't mean that you need to sit down with pen and paper and completely solve a problem before coding, this is an approach taken by some books attempting to teach software development. Some go as far to advocate for an even stricter approach, something along these lines.



  1. Model the problem domain with UML or some other modeling technique

  2. Translate your modeling into pseudo-code

  3. Translate pseudo-code into actual code

  4. Realize 2 month project took 2 years to complete

  5. Go to step 1 (the problem has radically changed since you took so long)


Of course, I'm poking fun at the books that take such a structured route. Here is a news flash for everyone Programmers are lazy. Here is another news flash (and this might actually be news to some people) Being lazy is good. Not all laziness is good, if it causes you to cut corners and fail to deliver a high quality product, than you fail at life. If however your laziness drives you to find an easier way to do things then "Lazy FTW!"


I have the "joy" of programming Java in my 9 to 5, when you write Java for a living you get used to the absurd amount of verbosity in your code, you also have the joy of Eclipse (notice no quotes around joy) that will write most of your Java code for you. Then there are things like Project Lombok that strive to make Java easier and more fun to write. C# got the memo, and let their programmers be lazy, let's take a look at attributes in a few languages


Here is some C# code to make a class called Foo with a string member called Bar that can be read and written
[csharp]
public class Foo {
public string Bar { get; set; }
}
[/csharp]

They realized people are lazy, let's look at the same thing in ruby


[ruby]
class Foo
attr_accessor :bar
end
[/ruby]

Again, concise and simple, let's look at some Java


[java]
public class Foo {
private string bar;

public string getBar() {
return this.bar;
}

public void setBar(string bar) {
this.bar = bar;
}
}
[/java]

Can you hear it? I can, it's the language architect saying "Just don't be so lazy, write those simple functions, it isn't hard." The truth of the matter is that it isn't hard, in fact Eclipse will happily write these functions for you, just hit CTRL-SHIFT-G. I'm sure there is a point here that I'm getting to, and here it is. I don't want to disparage Java or start a language war, what I want to point out is that Java has a different conceptual model than C# or ruby. C# has the concept of properties and ruby has the concept of attributes, Java doesn't have anything like this, classes have members and functions, nothing more.


The point is that the conceptual models your solution adopts will have huge ramifications on the implementation of the solution. There are many examples of unifying philosophies that make things simpler. Unix's concept that everything is a file, C++ concept of streams, Erlang's pervasive share-nothing message passing, ruby's duck typing. These are core concepts that have profound and far reaching consequences.


Working on a new side project I recently was struck by a way to simplify a complex data structure by adopting a new conceptual model. Creating an internally consistent, elegant conceptual model is the most important thing you can do for a project's success.


Conceptual modeling is a hard thing to get right, go into too much detail and your model becomes rigid and brittle, go into too little and the model can be impossible to implement correctly. Making a good conceptual model is like making a good analogy, there are a few hallmarks to a good conceptual model.



  • The conceptual model should simplify the problem domain. Files and folders greatly simplifies the concept of a hierarchical file system by relating it to something commonplace.

  • The conceptual model should not be overly complex to translate into an implementation

  • The conceptual model should be uniform and consistent, if you find parts of the problem domain falling outside the conceptual model or feeling "tacked on" you should rework the model


The next time a project seems stuck or overly complex, instead of refactoring code or attempting to throw another library at it, take a step back, look at the big picture and refactor your conceptual mode.

20091123

division of labor

[caption id="attachment_280" align="alignright" width="216" caption="cartoon labor"]cartoon labor[/caption]

When building or analyzing any system of significant complexity the most important thing to determine is a proper division of labor. The entire idea of n-tier architecture is built on dividing labor up into the appropriate tiers and keeping them cleanly separated. For anyone that's ever worked on a real world system half of the difficulty is caused by one layer leaking into another and the other half is getting around the separation caused by separation.


Despite my last sentence, division of labor is a necessary and good part of design. When done right it allows you to know where functions, variables, and constants should live, how things should interact, and who is the system of record. This is why it is imperative to decide beforehand or shortly into a project what the lines of demarcation are and who is responsible for what.


Prosper is one of a group of libraries, with well defined divisions of labor. This allows the libraries to be decoupled, and also has the added benefit of letting me know when I'm done. When I found myself adding functionality to Prosper the other day that I knew belongs in the next library, I realized that it was time to officially start the next library. So a new skunkworks project is moving ahead full steam, it contains 2 parts that work together, and so again requires a well defined division of labor.


Just because work has begun on a new library doesn't mean that Prosper is left out in the cold, yesterday I added support for the deprecated mysql library, standardized construction, and added better support for native functionality. If you are checking out Prosper, you can follow the latest development by pulling from the svn repo.


Back on topic though, figuring out the division of labor is the most important part of any analysis or design work. We recently at work had a 2 hour long discussion about order numbers. It went something along the lines of this:



BA: This order number comes from the Mainframe
Expert: No the Application creates that number
Dev: So, what does the SOA layer need to do?
BA: Generate the number
Expert: No, do nothing, the Application will automatically do it
Dev: Wait so who is responsible for creating the order number, and if its not the Mainframe why is it making one?
Expert: The Mainframe always made that number and the Application has always ignored it.
BA: So we will make it in the SOA Layer?
Dev: Who is in charge of making the unique identifier order number?!
Expert: [shrug]?
BA: [shrug]?
Dev: Let's decide that first

Explicit division of labor requires you to pull the unspoken assumptions everyone has about the system out of the silence of our own minds and puts it into the blinding daylight. Suddenly communication is smoother, arguments come to an end, because there is some record to consult to help guide decisions.


Draw out your explicit divisions of labor, don't carve it in stone though, if your original design ends up being too inflexible, allow it to change, but again, bring all the unspoken assumptions back out into the open. This allows you to cleanly define what piece is in charge of what function, keep layers from leaking into each other, and make for smoother development and analysis.

20091007

first step into web design

I have degrees in Computer Science and Mathematics, this means that I'm a huge nerd, it also means that I should, under no circumstances, attempt to design things. What happens when programmers try to design graphics? Normally they come out badly, our brains just aren't wired for making things look nice. There are of course exceptions, but do a google image search for "programmer graphics" and you will find thousands of examples of terrible, terrible artwork. Here is one I found that exemplifies what I'm talking about

Scary isn't it? Well us programmers and mathematicians should be kept far far away from designing things. We also like to break the rules and in that spirit I would like to announce that my first wholly designed site is now live. It is for my friend Tim's band, Cap City Quest.

I think the design is passable, what with blueprint css and jquery plugins, these websites basically make themselves these days. Making it did reinforce a very good lesson, Do what you are good at, farm out the rest

So this was my first step into an actual public facing site design. I think I did ok, if you have suggestions feel free to leave them here. If you want me to design you a site with sweet delicious jquery and blueprint and maybe even some dynamic content, leave me a comment. This site took about 10-12 hours of work, it was a quick one off project, but I enjoyed it.

If you missed the link up above, go and view it now Cap City Quest



first step into web design


I have degrees in Computer Science and Mathematics, this means that I'm a huge nerd, it also means that I should, under no circumstances, attempt to design things. What happens when programmers try to design graphics? Normally they come out badly, our brains just aren't wired for making things look nice. There are of course exceptions, but do a google image search for "programmer graphics" and you will find thousands of examples of terrible, terrible artwork. Here is one I found that exemplifies what I'm talking about


Scary isn't it? Well us programmers and mathematicians should be kept far far away from designing things. We also like to break the rules and in that spirit I would like to announce that my first wholly designed site is now live. It is for my friend Tim's band, Cap City Quest.


I think the design is passable, what with blueprint css and jquery plugins, these websites basically make themselves these days. Making it did reinforce a very good lesson, Do what you are good at, farm out the rest


So this was my first step into an actual public facing site design. I think I did ok, if you have suggestions feel free to leave them here. If you want me to design you a site with sweet delicious jquery and blueprint and maybe even some dynamic content, leave me a comment. This site took about 10-12 hours of work, it was a quick one off project, but I enjoyed it.


If you missed the link up above, go and view it now Cap City Quest