Blog moved – again.

•November 30, 2009 • Leave a Comment

You are welcome to visit the new blog at http://blog.smartit.se/

Communication issues when adapting outsourcing

•December 14, 2008 • 1 Comment

 

 
  clip_image002

Table of Contents

Communication issues when adapting outsourcing. 1

Background of Outsourcing. 3

A first view.. 3

Main benefits. 4

Adapting Outsourcing to your project 5

Handling work load over seas. 5

Communication problems. 5

Main problems. 5

Cultural problems. 6

Technical problems. 6

Outsourcing and Open source what makes them similar. 9

Open solutions, the advantage. 9

Marketing and new technology, community help. 10

References. 12

Background of Outsourcing

A first view

Let’s assume that you run a company, no matter if the company is big or small. Just imagine having to build a project where you know that your current staff either doesn’t have the right knowledge to solve this problem or the number of staff members is not sufficient. This is where your company will face a problem, either you hire some new personnel or you consider Outsourcing your project. In this text, we will talk only about outsourcing when it comes to information technology projects not any other work fields such as call centers etc.

So when browsing Wikipedia¹ we see that the following description is given “Outsourcing involves the transfer of the management and/or day-to-day execution of an entire business function to an external service provider”. This means that we can transfer our activities on our project to another country and have others take the work load. If we think closely on this, for how long has really outsourcing been available, when did it become easy to Communicate with countries far away? The answer is fairly easy, assume we had no internet and no computers, how would we then communicate with ie India? It would be impossible to this without our technology we have today. So considering a good interaction with computers is both a requirement and in today’s work spaces something that we can assume exists.

Outsourcing your project has in the last couple of years become a bigger and bigger way of solving company problems, these problems being Cultural, communicational and other areas of inconvenience as discussed by Sofie Alriksson².

This gives a good overview of what exactly Outsourcing is and how it’s adapted, now let’s continue discussing benefits and how technical problems might affect our work.

Main benefits

As roughly mentioned above the benefits of outsourcing in general is to take the work load of your staff or to gather new personnel. As mentioned by Sofie Alriksson², adapting Outsourcing is mainly because you want to work on your core activity and let others focus on the outmost parts of the project, having companies’ overseas working on your modules while you are focusing on the main frame.

When having a computer project the price today is often very high, especially the production const, personnel in ex Sweden is very high this will of course give a result that the project will either be rushed or that the company will not afford having the project running for long. By outsourcing your project this scenario might change dramatically meaning that the cost for personnel is much less and this giving more money to more personnel having the project released faster.

Adapting Outsourcing to your project

Handling work load over seas

One of the first things you might consider when starting a project is to have all the documentation ready, this means that having UML-documentation, project plans, time tables and other planning papers ready when outsourcing, because being over-prepared doesn’t exist in the world of outsourcing.

Another thing to consider is; how will the outsourced company handle regular deliveries? What project models do we need to follow? These are some key points to consider, which again takes us to the most important part of all, the computer interaction. We can’t have fairly good English speaking personnel overseas calling us in the middle of the night giving us a project status report. A lot of the countries where outsourcing is cheap, is in another time zone that where the staff is actually expensive.

So how would report on a daily basis work? E-mails might not be as secure as you’d like, because the service itself is not encrypted, meanwhile there are of course solutions for this, but not to take this too much off topic, I’d say that using a closed project platform such as Sharepoint or any other project organization software out there. You can probably find a lot on the open source community which you could customize for your needs.

However, let’s not talk more about the software to be used but rather how we use the selected way of reporting. This is something that we really need to point out to the outsourced company, how we want them to report. As mentioned before, being to clear on what you need, how you need it and when you need it, is never a bad thing.

Communication problems

Main problems

Outsourcing might sound very good and sure can be a good solution for your situation. However, there are always downsides with solution that presents them as being this perfect. These problems are taken up by both Sofie Alriksson² and Jeff Atwood³, besides from the obvious that your project might be shipped to India where you will have no visual perspective over the work, you might find troubles such as the ones Jeff Atwood³ states here “They get cancelled. Or the consultant who bid on the work never delivered, or delivered poor results. Or the client has unreasonable expectations, or doesn’t actually know what he wants.” What actually does happened if you bid too low and the consultant or outsourced company realizes this and in the middle of the process decides to quit? There’s no good solution for that problem, being repetitive is the best learning process, so here goes again, never ever give to little information.

Cultural problems

The above problems isn’t the only issues when adapting outsourcing, you might as well find that the cultural difference it way to big and this problem is clearly talked about in Sofie Alrikssons² paper, she also presents a possible solution which in this case was to inform the company where you outsource of your culture and how you like your work to be handled. It’s also very important that the hiring company has knowledge about the other culture, understanding is very important from both parties.

How does the cultural problem affect the computer interaction? For instance imagine outsourcing your project to India where they have totally different believes than we have here up north, this means that they might have different rituals than we do such as preying on a regular basis and on a specific time. If the hiring company does not have knowledge about this, what happens when we try to call them at this time, or when we assume to have something delivered? As you can see, this is not really a computer interaction problem, but rather a religious misunderstanding. But a cultural problem that actually will affect the interaction is the Technical perspective. Sweden per say is one of the countries in the world with the best technology, meaning that we might actually have different assumptions regarding technology and how we use computers, than the company in the outsourcing country. The reason for this might be a lot of different ones but for instance that the country is in general poor and can’t afford to take in new technology and adapt to the new standards. This is a very important point when viewing and discussing human computer interaction.

Technical problems

Some of the technical problems are talked about in the previous topic but there are another perspective than the “cultural technology perspective”, the upcoming issue is however a result of that problem. If you imagine the scenario where a company in Sweden needs a new application to be developed for the new mobile technology. If this was a couple of years ago, let’s say 2004 when 3G was fairly new in Sweden and the company 3 was the only ones having this. What if the company 3 would want to develop a new mobile application using the 3G technology, but the application is so advanced and needs a huge amount of staff members to complete. This is simply too expensive for a new company like this to invest in.

However outsourcing this will help and make it more cost effective. But outsourcing this to a country like India which might not yet have this technology, will cause an inconvenience. This problem will therefore make the project cost much more, since the customer needs to set up a test area and development area for this to be developed and from a strictly computer interaction perspective, who says that the people adapting this technology in India, will follow the same principles as we do here?

We need to keep in mind that different people think different and that different cultures are very different meaning; Applications created by an outsourced company might not be as you would’ve made it yourself. Keep in mind that we are talking about software and / or general computer development and research. With this in mind, how differently would you think that an outsourced company documents, programs and do other tasks differently from how you or your staff would?

This question brings up a huge problem when outsourcing, the technology and the way of adapting it, will cause issues between the parties and as Jeff Atwood³ said “For example, people asking for a clone of ebay for under $500”

A new company in Sweden that might not have any experience working with software development might think that it’s just typing as Jeff Atwood4 talked about. But this is in fact wrong, it’s complicated being a software developer and having to do with a software project might not always be so easy. Thus the applications that developers, managers and other involved staff members use has a quality requirement, they need to be top notch. Using such software and styles might not be widely known, a company might have its own developed software which they do not care to share with other companies. These are also aspects to take in mind when taking on a project which needs outsourcing.

Having discussed the benefits of using outsourcing and the downsides with the applications, culture and other aspects, we need to take a look at a final point on the downside this being, the result of the software product. We can assume that people from ex India are smarter and have another mindset than other countries such as Sweden, they work for less, they know they can easily be replaced, which leads to a harder work style. Now what can possible have to do with Human Computer Interaction and the “samrtness” of a population? Having a usage base that is generally smarter and thinks on a completely different basis will result in your application being made for this crowd. This directly affects the computer interaction, on the visual basis that is, because the hired personnel might interpret how to solve something graphically in a way you would never imagine.

Outsourcing and Open source what makes them similar

Open solutions, the advantage

Open Source is a very broad topic and will not be discussed thoroughly here. But the main purpose of an open application is that the community, being either developers or users can easily get the software and / or its source code; Source code being the logic for how everything behaves.

You could say that all software projects share a specific way of working and this is mainly the structure and documentation of the project. Some projects require this more than others; such as an open source project and an outsourced project. An open source application is often free of use, but there are of course applications that do cost money but are still open source. Either way, the most important part is to help the contributors understanding your business logic and the graphical user interface programming.

This is done by having good documentation and well commented code where you explain all the steps, of course you should never make code unreadable by adding to much comments, then the interaction with the code will just back draft.

When you create an open source project, you force this structured work way from the beginning, there’s no space for spaghetti code or ugly solutions. These parts will be replaced immediately and the programmer will probably not be welcome on this project further on.

This is a big advantage, letting the community contribute to your project and giving you a lot of feedback on it. However, what happens when you want to go global and have a paid for application? The contributors will then require some kind of assets for their work.

The feedback from the community is worth very much on a big project and might help you in long terms; the community is often willing to help out with the most outrageous projects just for fun or for experience. On an outsourced project however, you might not feel that you have the same commitment, however this is because you actually pay for something getting done, and you need to rely on the programmers to do their work. In an open source development you can’t force anyone to do your work.

Marketing and new technology, community help

Let’s play out the scenario where you somehow come up with an idea of a technology or a software that isn’t on the market, but you know that this will help the community a lot in many ways. A project of this sort might be an electric car or a car driven on water, however that has nothing to do with software projects so let’s not talk more about cars.

When you have this kind of idea you either want to make a lot of money or you want to help the public community, but who ever says that money isn’t equal to motivation lies. The main purpose of a project is, in most cases, about making money. So you stand before a dilemma, either you publish your diagrams, project description and other project plans on a public community forum or create a website where you explain your situation. Which then might actually lead to someone else stealing your ideas and benefiting from this which results in them being rich and you being back to square one.

But planning the project well and having good license agreements can help you on the way, you might state that if anyone works on the project they are entitled to their name being written in the EULA or somewhat like that. Keep in mind that an open source project might not be a completely usable alternative for an outsourcing solution but it’s a good point to take when we talk about computer interaction because both type of work requires some common work ways which are good to think about.

Having an open source project which grows big might not only help you development wise but also marketing wise, because having a lot of programmers sharing their thoughts and interface suggestions and so forth will attract a crowd.

And think about it, when having an outsourced project you need to have the following aspects top notch:

· Project plan

· Commenting templates

· Documentation templates

· Wiki

· Forums

· Bug reporting system

· Source control system

These are just the aspects that really need to be perfectly planned no matter if it’s an open source project and outsource project or a local project on your company. For human computer interaction purposes these need to be top of the line.

Can you yet see another similarity between open source and outsourcing? If not, let’s present it; People around the world contributing to software development. See that as a headline of both Open Source and Outsourcing and the two latter names as an “implementation” of this expression. When having an open source project you never know what culture a contributor comes from or which time it is in his country. This forces an adaptation to new technology and a generic culture understanding.

References

1. Wikipedia. Outsourcing. Wikipedia. [Online] 12 08, 2008. [Cited: 12 08, 2008.] http://en.wikipedia.org/wiki/Outsourcing.

2. Alriksson, Sofie. Communication problems by using outsourcing international . Communication problems by using outsourcing international . Halmstad, Halmstad, Sweden : Halmstad Högskola, 12 08, 2008.

3. Atwood, Jeff. Coding Horror. Can You Really Rent a Coder? [Online] 11 23, 2008. [Cited: 12 10, 2008.] http://www.codinghorror.com/blog/archives/001190.html.

4. —. Coding Horror. We Are Typists First, Programmers Second. [Online] 11 17, 2008. [Cited: 12 10, 2008.] http://www.codinghorror.com/blog/archives/001188.html.

5. David Axlund, VD Mailopages Sweden AB. VD. Karlskrona, 11 20, 2008.

6. Ekberg, Filip. The Art of Teaching. 05 : 12, 2008.

7. Masses, Development for the. Development for the Masses. Communication problems in outsourcing. [Online] 2008. [Cited: 12 10, 2008.] http://www.dev4masses.com/a_communication_problems/.

By Filip Ekberg and Göran Petersson

The Art of Teaching

•December 5, 2008 • Leave a Comment

The Art of Teaching

Filip Ekberg
filip.ekberg@bth.se

Abstract

A teacher knows that there are no straight answers on how to teach. There are multiple ways giving people new information and helping them adapt this in their current work. One of the preferred learning method by me is the Problem Based Learning, I will take up more about this in the upcoming topics. It’s also very important to take the age of the student in mind, how do they actually see on you as a teacher and does your and their age really matter?

1. Introduction

By passing on knowledge to new generations we somewhat evolve into a new and different kind life form. This not being as deep as it sounds, every day we somehow pass knowledge to someone. It might be the neighbor, a child, a sibling, a parent or anyone else for that matter.
The important thing to remember is that all new or old knowledge is dangerously important to pass on to those concerned. There are a million ways of teaching something, not all of them are good and not all of them are bad, being old or being young doesn’t matter, all the age gives us is perspective and understanding of how to pass on knowledge and whom to give it to.
By viewing the aspects of teaching, who needs to know what to be able to survive, complete a task or just continue living their life. Of what importance is all the facts, does one give the window of failure or does one give all the fact so that there is nothing left to learn?

2. Different generations

This might actually be a sensitive spot to touch, but I’ll be short in these words. There is actually a big difference between teaching 2 different generations. Imagine having a student which was born somewhere around 1960 and a student who was born 1980, depending on the age of the student and the age of the teacher, both these persons will take the information in two whole different ways.
If we would’ve taken me as a teacher example, I’m born 1987 which makes me not very old for being a teacher. Some of my students today are actually a lot older than me, which might give in to complications.
The different generations doesn’t only differ in age but in the attitude and the way of learning. A person born in the 1960:ies might have a harder time actually learning new things than someone born in the 1980, this is because, when this text was written it was the year 2008 which makes someone born in the late 1980:ies somewhere around 20 – 25. In this age, you have much easier to learn and take in new information.
Now this does of course not mean that someone born in the 1960:ies is stupid, rather that there are a big different and when teaching a group with a lot of different generations, this has to be taken into mind when planning a course.
Take another example such as a work place where your co-workers are much older, being young you rarely have anything to say on a work place where the stuff have been done in a certain way for very long.
So when trying to teach an older co-worker, you really need to sell the new information so that the older generation will be more interested.
But going back to the topic of teaching in a class room, it might be a benefit of being older, because older generations have much easier to focus and having a different mindset which will help them succeed.
It’s very important to respect each other, despite the age difference, if a younger person knows something that the older one doesn’t, it’s very important that the senior gives the younger person a chance to actually come forth and tell the information, that might in fact help production or whatever the work space might need.

3. Teaching differentials

There are a lot of different ways of teaching and what should be kept in mind when talking about different methods and where they apply is that everyone is different. I might not find it as amusing as you would, if I were forced to be taught with the old style teaching methods.
Thus, as stated in the upcoming topics, there are benefits of the both methods and there are of course a lot more out there, but the ones that you mostly see in action, would be these two.

3.1. Problem Based Learning

I would certainly say that PBL; Problem Based Learning, is my favorite method of learning. Ever since high school this has been a method that I’ve worked with.
The principles are that a student is given an assignment and there are known factors of failure which will somehow help the student learn what is necessary. After working with the problem for an amount of time, the solution will somewhat appear and the student has learnt something new.
There’s also another aspect of this, or rather, another explanation. Let’s take implementation of the sorting algorithm quicksort as an example. This is a fairly hard algorithm to master and it requires some base knowledge in the field. So when given this assignment, the first obvious part from the teachers perspective is that the student will somehow search for information about the algorithm.
Using internet or a special course literature, both should work very well. This gives the student an opportunity to master this assignment on his or hers own means.
When all the information is collected and the next phase in the learning process begins, which in a programming line of work would be to put up a structure of your software, in this case the software won’t be huge but having a pattern when working is always good, no matter the size.
As a result of this method, the student will have taught him or herself something new and by the individuals own needs.

3.2. Old Style Learning

As a matter of fact, the “Old style” in from my point of view might not be what you would suggest as an older style. And I am not talking about the old school tutoring where the teachers would be rude and make students learn by force and learn by fear.
In my eyes the old style would be where all the answers are somewhat given and there is no room for self teaching or in any way, a path given where the student can choose to learn just what is needed or learn so much more.
This old style can be seen at many high schools throughout, in my experience, Sweden. Now, the old style, what exactly defines this and are there any benefits? Well to start off, the old style learning method is where the students are put down at a desk, everyone directed to a whiteboard, and the teacher is using a pattern of teaching, where the pattern repeats itself. The old style pattern is when the teacher enters the room, greets the students, and starts talking and then when a question is stated an answer will be provided directly.
Now this point of view might be a little bit dull and it certainly has its good parts, they are just somewhat harder to find than the good ones in a problem based situation.
We have to keep in mind that everyone learns differently and that it’s important to give everyone what is needed to succeed. Thus, this method works in some cases but I would say that it wouldn’t work in most cases.
A benefit of the problem based learning system which the old one lacks is that you give a broader room for questions and thoughts and it’s fair to say that it requires a totally different mindset and maturity.

3.3. Which is best?

Giving an answer to that question would be somewhat impossible. Just not because everyone differs from each other so much, but in some situations I would also prefer to be tutored using the old style method.
The assignment stated in the PBL-example a couple of words back is a great example of how you can absorb new technology and new point of views. Programming itself is very broad and there are hardly any similar solutions out there. And the quicksort implementation sure is a defined structured algorithm but it can be implemented in so many different ways, it doesn’t matter if there are fewer rows or more rows, and they are just all different.
Which in the end would make you to consider how others are implementing it, what are the benefits?
Using the old style method, the tutor would just present some ways of implementing it and not giving you as a coder any room for own thoughts. A teaching method is always abstract in my eyes, you can’t tell someone to just go with a method, because “implementing” PBL differs from time to time.

4. Team work is important

You might think “What does Team work has to do with everything?”; Well actually team work has everything to do with learning. By being a tutor on various programming sections I’ve reached to the conclusion that team work is the most important part of learning and teaching. Now, team work isn’t all important only in the case of teacher to student teaching. This is also very important when we talk about teaching in a workspace.
Since I generally work as a programmer, the examples of programming workspaces suits me the best, so here goes. Imagine having a workspace where there are 10 – 20 developers, 5 graphical interface programmers and a couple of designers. These all parts need to co-operate for the development to work. If some of the staff has knowledge that someone else doesn’t, it’s very important that if this knowledge will help the company produce more, then this person needs to convey this to the rest of the staff. This is where the team work is important, if someone on the staff feels insecure with conveying the knowledge; this person is probably not right for the position.
I always say that when I work somewhere, I don’t want to be the brightest and the person with the most experience, this is because I want to learn, learning is very important and knowledge is worth a lot.
And if you’d come to a workspace where people is unwilling to co-operate, sure this workspace lacks team work and this will be disadvantage when you want to learn and grow professionally.

5. Sharing is caring

Not only does sharing rime with caring but it goes very much hand in hand, almost every time that is. In this case, sharing knowledge to your co-workers, students and family is very important. Especially when you work as a teacher, the sharing part is not only important but it’s a factor for you, keeping this job.
I’ve met teachers who felt threatened by me as a somewhat quick learner and bright student, not to sound too self-righteous this was actually a problem for me when I went to high school. I had teachers that, somehow, felt threatened by my knowledge and therefore didn’t want to share new knowledge with me.
This is a dangerous way for thinking and teaching, you always need to take the student, no matter if it’s a co-worker or an actually school student, you always have to see the people you are tutoring new things, to be your student.
And a student is to be handled with care; your personality will in the end reflect in this student and will show everyone, how good of a teacher you are. Of course some people like to learn themselves, but, put your mind around this, initially how do you give someone inspiration? It’s by showing the person what skills you have and maybe how you’d do some things.
Sharing knowledge is in the end a vital factor for evolution, what if Einstein or other important people for our evolution, wouldn’t share their findings? How would this affect our current living environment and our current ways for thinking?

6. Feeding answers is dangerous

However, when sharing information it’s very important that you do this correctly. As mentioned in the previous chapter, all people learn differently. This is probably one of the hardest parts by being a teacher; you need to find a common spot which almost all students like.
Of course this is often impossible, thus there are more than one path to take and there are almost always presented two or more ways for the students.
One important thing to always keep in mind is that you can never ever just give out an answer to a question without somehow providing a solid explanation or a proof why it works.
Why you might ask, this is because when being a student, you are almost certain to always take the easiest path and not thinking clearly about consequences. By being spoon feed you will never really care about how or why the solution is what it is.
And being a programming tutor, this part is very important, what if I were to give all the students the correct answers to all assignments, and tell them “Here are the answers, go find out why”. Maybe a couple of percent would actually find out why the answers are as followed but the majority wouldn’t. So to keep in mind is that when a solution is presented, always give out a good and pedagogic explanation to why.
This topic actually doesn’t just apply to students, it’s also very important not to just give co-workers the answer and let them be happy about it. I know that sometimes I just want a quick answer, but when I actually encounter the problem the second time, and not knowing how to solve it, I regret not doing more research the last time.

7. Giving inspiration not motivation

Not to feed answers and giving inspiration is actually something that we can see go hand in hand. When you actually want to teach someone something you want to give the person inspiration and give them the mindset of wanting to learn.
So why wouldn’t you want to give someone motivation? Motivation isn’t something that can just be handed out, actually motivation is something that I would say comes hand in hand with inspiration, when someone is inspired, the motivation might peek and giving co-workers and students inspiration on a regular basis might in fact help the persons succeed and somehow indirect force them to teach themselves.

8. When open source helps programming tutors

Talking about open source could be a completely separate paper and take up many pages of explaining why this is a good way of learning and working.
First of all, what is open source? Open source is a way for providing your product open and free, not only the software itself but also the source code, which defines the business logic, the graphical programming and other aspects of the program. This is a definition from Google [3] on open source

“A program in which the source code is available to the general public for use and/or modification from its original design free of charge.”

This is actually interesting, companies, people and organizations giving out their source code for free, so how does this actually help a learning process? Well for starters, there are software available for development and making office work more easy and there are so many softwares out there that can and will help you learn new ways.
The topic on open source now is very programming tutoring oriented and might not really be of interest if you work in a construction site. But think of it like this, what if there were some free ways to actually make your construction work easier?
When teaching programming we often come to points where we do reference an open source project, Linux is one of those; Linux is a kernel for the GNU / Linux operative system. This kernel has from the start been open source and the community which uses it has always been very helpful and made this a better product.
Now, working on a project like linux might not be very easy, but it does in fact give you knowledge, this is an very important time to take up that you always have space for new knowledge and you are never too old to be learning new things.
Programming on linux or any other open source projects might require that you actually have some experience from the start but you will also gain so much from being a part of this process.

9. References

[1] David Axlund, VD Mailopages Sweden AB – There might not be any direct references in the text or quotes from David but he has given me a lot of inspiration when it comes to management and giving people knowledge.

[2] Filip Ekberg – I have myself in this text as a reference because a major part of it is from own life experience .

[3] www.google.com http://www.google.se/search?hl=sv&q=define%3A+open+source&meta= 2008-12-05 – Definition of Open Source

Polymorphism – A Practical Example

•November 13, 2008 • 2 Comments

Classes, inheritance and polymorphism can sometimes be somewhat hard to understand. So a practial example suits many well. Therefore this will be a tutorial where i will touch the areas of classes, pointers, inheritance and polymorphism.

So to just clearify some expressions i will add a little dictionary at the top:

Class
A class can somewhat be seen as a blueprint of your object. I.e. having a blueprint for a building, then this would be the class. Then a Constructor would build this to become an actuall touchable object.

Inheritance
When you inherit something you can think of it more like you extend this thing. I.e. having a Car and then having a Sports Car where there are some new variables to it. The Sports Car is actually a Car but it’s also extended with new properties.

Polymorphism
This is taken from Wikipedia: “In simple terms, polymorphism is the ability of one type, A, to appear as and be used like another type, B. In strongly typed languages, this usually means that type A somehow derives from type B, or type A implements an interface that represents type B”. Read more here

Pointer
For a pointer explenation look here

I will be using Visual Studio 2008 with the built in C++ compiler for the following examples.

A good practice will be to create a Bank, when you get a new assignment or just want to create something new, start by thinking about the structure, what actuall needs does this have? Well when creating a Bank i think to myself that i’d like to be able to create Bank Accounts, attatch these to People and you can go on and on.

But, for the example i will only go as far as creating a Bank, a Bank Account ( Abstract ) and a Student Bank account which is the only Bank account you can actually get.

So creating a simple diagram over the project, i got something like this:diagram So now we have a Bank, Account and Student Account, what kind of variables do we need?

Bank
Bank Name
Accounts

Account
Balance
Interest
Max Loan
Account Holder

Student Account
Amount of Deposits
Last Deposite Month

So the big difference between Account and Student Account is that the Student Account have different rules than Account and therefore calculate a lot of things differently. We won’t go through all the logics. There will of course be a window for you to evolve this application as you feel nessesary.

Now when we have a defined structure we can start by creating a new Project and it’s files. My project will be called Bank and the following files will be placed in it:

  1. main.cpp
  2. Bank.h
  3. Bank.cpp
  4. BankAccount.h
  5. BankAccount.cpp
  6. StudentAccount.h
  7. StudentAccount.cpp

When all my files are created a start by definint my program entry point, this being my main. Notice that i will be posting code snippets as pictures, because you should Write this yourself and not copy my code!

1

We prepare for an input/output stream by including <iostream> and setting using namespace std;

Now the next part is to define the Bank.h We need an appropriet constructor, desctructor and some access methods, remember to never open up member variables publicly!

The #ifndef part is important for the compiler, we dont want to define our header file more than once, because that is not nessesary!

2

I assume all the parts are clear except the last one, read more about how that pointer type works in the previous post here on my wordpress.

The implementation itself will be up to you, i will only be showing the structure, header-files and some code from main and where polymorphism is concerned!

The next file to create would be the BankAccount, remember to add #include “BankAccount.h”  to Bank.h when it has been done. Otherwise the BankAccount *accounts array will fail because undefined symbol.

Back to the third file, the BankAccount.h this is how i would structure it:

3

The part to look deeply on here is the Deposite method, watch closely, it’s defined as followed: virtual void Deposite(double amount) = 0; So this method is expected to be overrided in a inherited class and it has the return type of void and an in parameter of the type double.

Now the next file to create is the StudentAccount.h where we will be deriving from BankAccount.

4

So the following class StudentAccount is extending a class called BankAccount. So this means that StudentAccount is a BankAccount with extended properties and/or overrided functions.

Now, look closely again, here we have the virtual void Deposite part again, but without the =0, so this means we will be creating a definition for this function.

Also the Amount of Deposits and Last Deposit Month is just there to simulate some properties that might be nessesary to do something on a student accont. In my case this is for the Deposite. A Student Can’t deposite money more than three times per month, this is because a student gets 2% interest everytime they deposite money.

This is my Constructor for StudentAccount

5

As you can see, we pass the Variables Owner and Deposite back to the constructor of the base type, being BankAccount.

Now this is how my Deposite Method is implemented:

6 

Now the last think i want you to look at, is my final Main:

7

I want you to try and create all the nessesary functions in Bank.cpp, BankAccount.cpp and in StudentAccount.ccp to get the following output from this Main.cpp:

8

I would happily answer any questions about this project. A link to the complete source code is here

Pointers & Double Pointers

•November 11, 2008 • 2 Comments

Definitions
First off, we need to clearify what a some of the expressions i will use mean. These are the following expressions:

Stack
Assuming that you know about a computer having RAM ( Random Access Memory ) which allows you to store information and have this accessable faster than you would on a secondary memory like a harddrive and/or cd-rom.

When a program is executed there is a part in the memory reserved for this application to use, this “space” is called the Stack; The stack is always the same size and it’s not possible to change it’s size on any way.

Heap
The Heap is also a “space” on your memory, actually it’s all the memory not allocated as a stack. So when your stack is defined, everything else can be expressed as the Heap.

Pointers
What is a pointer really? A pointer is a globally used expression to reference that your somewhat “point” to something. See the following illustration

p1
On this image we have something that we point to, let’s call A our Object. So having A as the actualy object, play with the thought that B and C isnt there, and there are no pointers to it.

This would infact mean that we had A allocated on the Stack. When does this become a problem? So play with the thought you have a really big information base such as a User Layer where you store a lot of data on each user. Then havnig a big register on all the people attending a course would take up somewhat a bigger space than we have free.

When is is an issue, we can use a pointer, to reference to this object. You can of course point to an object that you have on the stack, but that’s not. afaik, what it’s initially intended for.

So we tell our program that we want to create a Pointer, this pointer will in fact be stored on the stack, but a pointer only takes up 4 bytes so this wont be a problem.

After creating the pointer, we create the object itself and have the pointer B point to this.

Pointer, Objects s & Arrays
Assuming you know about some object orientation and how an object is constructed i will not go in to this very deeply. I.e. we have a class called Person and we want to create somewhat a register over students attending a course, what we initially want to do is create an object array, where we can store all our persons, using c++, as i will do in the following examples you would write something like this:

Person *attendingStudents = new Person[size];

Where size is equal to the max amount of students.

Running this code, the constructor of Person will be runned as many times as the size of the array attendingStudents. How is this a problem? This becomes a problem when we dont want to run the default constructor and allocate the object size  as many times as the total array size, this has too much overhead.

First of all, how does this look in memory? 

p2

On adress 0 to adress 3 wnicn means 4 bytes; every memoy block is 4 bytes; the pointer attendingStudents is allocated and on that area a 4 byte long adress is stored which in our case is 84. The size of the given Person object is not given but just play with the thought that its 4 bytes and the size is 10 this would mean the total size of the Person array would be 10 * 4 = 40 Bytes going from the address 84 to 124.

However, let’s say that the Person object takes up 4 times as much so it takes up 16 bytes per Person object, this would result in 16 * 10 = 160 bytes, going from address 84 to 244. Now, there is a big overhead if we dont use all the persons and it would be stupid to call the constructors twice.

So, how about, we just point to something that we know is a pointer, and then let this poitner take care of the rest? But we just initialize the first step?

Double pointers
Thjis is were double pointers comes in handy, look at the following code:

Person **attedningStudents = new Person*[size]:

This code is not as straight forward to look at, as the pervious one, but it basically means, 

Person **attendingStudents  = Create a reference, to a pointer, what is a pointer? A pointer is something that will in the end point to a data type, so what we do here is saying that Point to a Pointer, this pointer will eventually have the data type Person.

Just to clearify, a pointer to an array, initially points to the first index in that array. So after creating the Pointer to a Pointer we tell it to point to a new list of Pointers, the amount of pointers to create is the same as the digit in size.

This might not make any sense, but take a look at the following

p3

Initally these pointers don’t point to anything at all so what we can do is: attendingStudents[i] which will take us to the adress 84 and then create an object on this index by doing this: attendingStudents[i] = new Person();

Why is this method better than the one before? Well this assures that we Only have the 11 pointers which takes 4 bytes per pointer. 1 pointer on the stack, referencing 10 pointers on the stack. When does this give us overhead? This gives us a 4 byte overhead when we start creating our Persons. But the execution time saved and just given 4 bytes ovearhead per pointer, this is a preffered method by me.

Importance of good Architecture, Structure and Patterns

•August 22, 2008 • Leave a Comment

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!

Big O-notation

•August 18, 2008 • Leave a Comment

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 ++ )
   {
      print numbers[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
  • increment

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.

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.

Objects, Objects, Objects!

•August 8, 2008 • Leave a Comment

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
{
    int m_ModelNr;
    string m_Name;
    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
{
    int m_DoorType;
    int m_Weight;
    int m_Code;

    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.