Often when developing software such as websites, windows ( or any other operative system for that matter ) programs, the begining of the progress is quite simple; you have your ideas and may have some thoughts about how to implement everything. But what often is forgot when developing software is the importance of thinking ahead, thus, planning for a larger software that you have in mind.
For an example, when i started developing SmartIT Invoice i thought of it as a software that would generally help me organize my small amount of invoices. But as the years pass my company grows bigger and bigger and once im up to n-numbers of invoices, a simple List View won’t be sufficient. Therefore after implementing my Invoice software, i started thinking about how i could change everything and structure the code for helping me in the future. I had in mind that i might not always want to use the Windows Graphical Interface for input and output so as i always do, i seperate the Design code from the Logical Code. This meaning that my application has three layers. Them being:
- Application Layer, code for display, handling window events
- Logic data layer, database connections, objects
- Data layer, this being the database with functions, views and procedures
By having these three layers i can easily change one of the layers without changing the next. Of course this is not entierly true, i would have to change some parts in the Logic Data Layer if i changed the DBMS. I would however not have to change that much if i just changed the behaviour of a Stored procedure.
Again takng my Invoice softwre as an example, i recently released a software called Webexpress.nu which allows customers to create their own website and for this i need somewhat of a payment system. Of course using Credit card payments is nice and easy but not entierly nessesary. So by just adapting my Webste to the current Logic Data Layer of my SmartIT Invoice software, i could easily get an intergration that allowed me to create customer invoices that pops up on the user account, when they are online on the page of course and even directly to my software, withouth any adjustments in the Data Layer or in my Windows Software.
This proves the point that well structured code and seperate layers will help you along the way of program development.
As a side note the Data Layer in this case is a Windows DLL with .NET 3.5 code which makes it even easier to implement when the website itself is asp.net with .net 3.5.
There are a lot of good design guidelines out there which will help you structure your software better and help you understand how to always follow a pattern. A pattern doesn’t, in my point of view, have to be a pattern like Singelton etc, it can by any means be a way for yourself to regocnize your own code, thus following a pattern. Example, i often tend to use m_ before member variables and write all functions and access methods with a capital letter.
Have fun programming!
Vote on HN
So starting school in a couple of weeks and being told that you wont get any “allowance” from the state makes you think twice about your current situtation. Not that this has anything ( directly ) to do with o-notation. However this is how i forced myself into learning it. I have to re-take an exam in Algorithms and Datastructures this upcoming week and i want to share my experience in big o-notation.
So basicly we have an array, a list of some sort and somehow we need to go through each element in this list. Having ‘n’ elements we need to create some kind of look like this:
void walkList(int numbers)
for ( int i = 0 ; i < numbers.lenght(); i ++ )
Now this will print all the elements contained in the list of numbers. Lets look at this from a time complexity way, 4 constant operations these being:
- function input
- int i assignment
- i < numbers check
And the loop will run ‘n’ times meaning we have n + 4 this will give us O(n + 4), but constant access times are irrelevant talking about runtime so all we do is write O(n). O, ordor as it is pronounced, is a way of stating the time complexity.
Now lets say we need to process ths array in another way, play with the thought that we have this list of numbers and for each number we want to go through the list again. This would give us a nested loop and give the time complexity O(n^2). This meaning that we need to process the list twice for each item, hence n ^ 2.
Looking at a sorting algorithm like Merge Sort that first divides the list into 2 peices untill its at the last item, then merges them. We see the typical behavior of a log() with the base 2. So, the split / sort part is basicly log(n) while the merging part is n and log (n) * n = nlog(n) which is slower than log(n). There are however no “standard” sort algorithms that can do better than nlog(n), in a random case that is. Best case for i.e. bubblesort is log(n) and worst case for bubblesort is log(n^2) which is slower than mergesort.
When is time complexity nessesary? I would say that during all my years of programming, learning speed, size and other performance parts the hard way, i would say that this is a very good complement to fast calculate time complexity of your algorithm. You can be a very good programmer without knowing a lot about this. A lot of this is just something that a programmer knows how to handle without knowing O-notation. But as said, a good complement.
Vote on HN
By looking on everything in life as Objects is one of the benefits from doing object oriented programming. It doesn’t really matter if you master the technique or if you are in the beginners stage, just starting with object oriented programming will open up your eyes.
Seeing how objects change your perspective on both programming and other stuff in life, i’ve notied that when i wanted to learn something like animating in Flash, knowing object orientation helps. Not particulary with the animating, but with the thoughts on how i will structure my animations.
I.e. that i have to create a move, where a part in this move occures many times, repeatinly creating this scenes and moving them around is a fairly harsh work. Looking at it from an object oriented perspective you see that you have:
A main film
An object containging the scene
When needed, you just insert a new object of the scene and you never need to repeate the procedure of creating the scene.
Using Objects isn’t always good though, when you need to store the memory on other medias than the RAM you need it to be serialized, which is not handled to good by some languages such as PHP.
The basics of object orientation is easy to learn over a few minutes, when you try to look at everthing at a new perspective, the learning period will decrease.
Let’s say that you have a Car, this car has 4 wheels, 5 doors, 6 windows and so on. The doors got handles, the wheels got air in them and so on. Seeing all these parts as Objects is a good way to play with the thoughts of object orientation. See how i apply inheritage on a car:
abstract class BasePart
public BasePart(int ModelNumber, string Name)
m_ModelNr = ModelNumber;
m_Name = Name;
Everytime you create something, the created part / object or wathever got a Model Number and a Name, just look at carparts or a coka cola bottle.
class Door : BasePart
public Door(int DoorType, int Weight, int Code, int ModelNumber, int Name) : base(ModelNumber, Name)
The codesnippet above shows the basics in object orientation, this is a Base Class which is Abstract, which means that you cannot create an object of it.
The Door is derived from a BasePart because its a BasePart.
Vote on HN