Tuesday, December 22, 2009

Model View Controller (MVC)

My family should now be saying, “Yea! Another blog post about techie stuff!” Yep, this is another one of those, but this one goes past techie. It’s for programmers!

The MVC is a way of separating and decoupling the three major pieces of a program and is done usually through the use of interfaces. You have the Models, which are the classes the data is “stored” in. These models are also the base level that programmers start. They are how your data is defined. The View is exactly what it sounds like, what the user is going to view on the screen. The Controller is the brains of the outfit. It is where the program starts moving and shaking and spitting out data that the user didn’t know they had.

That is a very basic way of describing the MVC. My definition goes a little beyond that. If you really want to decouple the objects in your project, you need to have to Controllers, View Controller and the Data Controller.

To me this is the only way to keep the views from really knowing how the data is handled. Some will say that you only need one Controller and it can handle the views as well as the data or it’s the Views job to handle how the program looks and feels; but if we are going to break things down, why not break them down into Single Responsibility objects ? The View Controller handles the views and the behavior of the views and the Data Controller handles how the data is presented and manipulated.

So I guess I have my own philosophy of MVDCVC (Model View Data Controller View Controller). Really not sure if I should put this out there because it’s not a refined way to look at it, but, here you go. Let me know what you think.

Tuesday, December 8, 2009

Picking a Standard Users PC

I’ve been asked a couple of times recently what to look for when buying a new PC. What I am going to post is not the norm, something I will probably be questioned and razzed from my computer friends that might stumble on this, but it is how I feel it should be handled, especially when on a budget.

First, pick your price. When picking a PC and without customizing it, the biggest consideration is going to be price. Picking a target price will help you decide what you need to look for. After picking the price, you have to realize that sometimes to get what you want you have to be flexible to a small degree.

The next thing to consider will be how you are going to use the new PC. Are you going to use it for photo storage, video editing, games, word processing, browsing the web, business applications… Some software will require higher specs such as video editing and gaming.

After you figure out what you are going to use the PC for, you need to get down to the specs. If you are going to use the PC for storage you obviously need to pick the PC with the greatest storage space. It is not unreasonable to find PCs with 500 GB (Gigabyte) , even 1 TB (Terabyte) and larger of storage space.

I do not remember the pixel size of the camera I used for some of the pictures on my computer (I believe it to be 5.0 megapixels), but the average is just over one MB (Megabyte). There are ~1000 MB in one GB. This equates to just under 1000 photos to one GB. You also have to take into account that the operating system will take up some of the space as well as any installed programs.

One advantage to storage space is that it is relatively cheap. If you need to keep your price down, there is always the option to get less storage space on the PC at the time of the sale, and then later adding an external hard drive for more space.

When storage space is figured out, it’s time to try to figure out the RAM. The more RAM you get, generally the faster the PC will be, but there is one major thing to remember. If you are buying a PC that has a 32 big operating system, then don’t get more than 3 GB of RAM as the hardware can’t handle more. If you are buying a PC that has a 64 bit operating system, then get as much as you can.

The last thing to consider is the number of processors. The more processors there are inside the PC, the more it can do at one time, hence speeding the system up. Dual Core PCs will have two processors, Quad Core PCs have four.

I also have to recommend that if you can get a PC without all of the trial software, it would be a major plus. It can take some time to weed through some of the preinstalled software and remove the unwanted software. Don’t be fooled when it says that it has Office (looking at you Microsoft) installed. It is trial software that will last around 60 days, then you have to buy it on top of the price of the PC. There are alternatives to Office that are free, but that’s a topic for another time.

Buying a PC can be a tricky adventure and should be handled with care. If you haven’t bought a PC recently or haven’t been keeping up on the current prices of PCs, don’t be surprised at the deals you can get, they are out there!

Tuesday, December 1, 2009

Unit Testing and Test Driven Development

This is usually a blog for the family, but this is a topic I need to write about, and I apologize to them for that. So, if you’re family reading this, it’s ok to quit reading now, boredom will ensue!

It’s taken me a little longer than expected but I think I am getting the hang of unit testing… or at least the idea of it, I still don’t implement it as much as my boss would like. The more I look at it the more Unit Testing makes sense, but there is one huge hang up. When you design a test, you have to take into account that data changes. I have been doing and seeing a lot of instances where the tests have hardcoded values in them. This poses a huge problem when the data has to be wiped and a fresh start is required or if the data simply changes. It causes daily builds to fail and then you’re stuck fixing the test when the application is just fine so you can get rid of the nagging messages saying that the build is broken. This is just a waste of time.

Unit testing is a building process, just like software development. You have to start at ground zero with ambiguous methods to get data and to get the data you need. From there you can create more complex tests and have them not be dependent on specific values, because the methods have been created for you to use to get the data; specific values are not good.

It is still hard for me to start with the tests and build the software from there as Test Driven Development (TDD) entails. Then, after you have data manipulation mastered you can start on the user interface. That is not the way I was programmed. This requires forward thinking and a knowledge of how the program is supposed to work. I was taught to start with the user interface (because that is what the user sees) and make the software work the way the user wants to see it. This has led to some clunky programs (Matt, if you’re reading this… HUSH)!

I can see where Unit Testing and TDD come together to create clean, and in some ways more simple, back ends to applications, the trouble for me is the thinking part.