Fremus.co.za

Demistifying Life and Web Development

Archive for December, 2008

Printing a sentence in reverse with C#

Ever wondered how to print the text in a sentence in reverse? Well here is a C# solution that I came up with after reading chapter 9 of Jesse Liberty’s Programming C# 3.0. The array object has a method that can reverse the content of the array. Yeah as simple as that. So basically what you do is read the text into an array and reverse the array.

namespace ReverseText
{
    class MyReverseText
    {
        static void Main(string[] args)
        {
            string myText = "This is my sentence";

            string[] arrayNo = new string[myText.Length];
            for (int i = 0; i < myText.Length; i++)
            {
                arrayNo[i] = myText.Substring(i, 1);
            }
            Array.Reverse(arrayNo);
            PrintMyArray(arrayNo);
        }
        public static void PrintMyArray(object[] theArray)
        {
            foreach(object obj in theArray)
            {
                Console.Write("{0}", obj);
            };
            Console.WriteLine("\n");
        }
    }
}
  • Share/Bookmark
Tags:
posted by fr3dr1k in C# and have No Comments

Comparisons between Java and C#

Yesterday I came across a link that shows you how different OOP concepts are applied by C# and Java. There are quite a few differences between the two and then there are some instances where they are almost similar. Both languages are from the C-family and the syntax looks similar at first glance, and I am willing to bet that it won’t take that much of an adjustment to learn either if you did either before.

  • Share/Bookmark
Tags: ,
posted by fr3dr1k in C# and have No Comments

The situation in Zimbabwe

It’s so unreal thinking about it, knowing that 2000km from Cape Town a human tragedy is happening and unfolding and it really seems as if the political leaders really don’t care about the plight of innocent civilians. Why does everything have to always revolve around power? A struggle for power and control, that’s what its all about. I’m ashamed, really to be part of a government that is standing by and letting all this happen. Read this article by Michael Trapido on ThoughtLeader.

  • Share/Bookmark
Tags:
posted by fr3dr1k in News and have No Comments

C# Design Patterns

Yesterday I started reading this book firstly because it dealt with C# and secondly because I never gave design patterns much thought. It was great to see that the book is written by a South African, Judith Bishop. I’m hoping to better understand design patterns. My current understanding of design patterns are that they act as a frame of reference for projects, so that when you develop a particular application you can refer back to a design pattern and understand which .NET name spaces are appropriate for that particular project.

Hopefully I will be blogging about this quite a bit more.

  • Share/Bookmark
posted by fr3dr1k in C#,Design Patterns and have No Comments

Starting a new job…and setting goals for 2009

I resigned earlier this month, the 1st of December 2008, to be exact to go join a group of .NET developers. I have been going for interviews for the last six or seven months, and honestly it has not been an easy trip. Simply because I realised the amount of time I spent working at my current job (4.5 years) didn’t relate as well to hard core experience, but I felt I had to make a move into an environment I wanted to be and where I see myself. I fell a little short in a view technical interviews, but also managed to outstrip a few guys with way more experience than me, but I just didn’t cut it for those employers. But eventually I found an opportunity, and I start on the 5th of January 2009 at this new job, which is both exciting and nerve racking at the same time, because I will not be permanent.

My goal for 2009 is to become a proficient to intermediate/advanced C# developer for any platform (mobile, desktop or web).

  • Share/Bookmark
Tags:
posted by fr3dr1k in General,Personal and have No Comments

Top 10 tech embarrassments you’ll want to avoid

I read this article and I cannot imagine how embarrassing it must be to have porn pop-up during a presentation, or to have private conversations appear. I guess we all live in our own bubble too much.

  • Share/Bookmark
posted by fr3dr1k in General and have No Comments

3 things I learned from 2008

2008 has been an interesting year, my 28th, and in this year I have learned a few things, but some really stand out:

  • Do not isolate yourself in your field of expertise. If, like me, your goal is to become a proficient C# developer then you have to make sure that you constantly measure yourself against best practices. I realised that even though I was achieving business goals I was not doing myself any favours with the way I was programming in C#. I realised that my ways arent that great when I went for several interviews at several companies, and did their tests. The tests made me aware that I am not up-to-scratch with what I have in mind for myself and where I want to be.
  • Consistent hard work over a consistent period of time is way better than less work and a big performance once in a while. If you get the big performances wrong then you have done nothing, but if you do things consistently over a period of time, then you achieve two important things:
    1. You build and prepare better for a bigger performance
    2. And you would not have done nothing

    This applies to programming in particular. Programming is tough, but if you spend enough DISCIPLINED time on it then it becomes less difficult, and it becomes easier to put bigger things together.

  • Knowledge management is important, and knowledge transfer is also important.
  • Share/Bookmark
Tags:
posted by fr3dr1k in General and have No Comments

My Top 5 .NET Resources

I use Google a lot for .NET resources, but I do have a few places I read a lot, and not just to get solutions but also to read about other people’s solutions. Reading about other people’s solutions is a key to learning, and learning is important to any developer’s success. Here are my top resources for .NET related topics:

  • ASP.NET Forums: Ever noted that a lot of the Google search results for ASP.NET point to posts on this forum. Do yourself a favour and register, and try to visit as regularly as possible, try and answer a few questions, or just read the solutions that are posted there. You will learn something. The posts are very fresh and is updated by the minute, so the content grows, so no chance of stagnant content.
  • Scott Guthrie’s blog: This blog has all the latest stuff on it, from ASP.NET MVC to Silverlight. If you want to know whats new make sure you read this blog.
  • Shine Draw: Looking to do something in Silverlight that you have seen done in Flash? Take a look here and maybe you can draw some inspiration.
  • 4 Guys from Rolla: Scott Mitchell has written a lot about .NET, and I read his article about URL Rewriting in ASP.NET on MSDN, so the articles on 4 Guys From Rolla really cover relevant and good topics. I also found that they write the articles in relatively easy to understand language.
  • Codeplex: Is Microsoft’s Open Source project hosting site and contains a lots of .NET projects
  • Share/Bookmark
Tags:
posted by fr3dr1k in ASP.NET,C# and have No Comments

Abstract classes vs Interfaces

What is an abstract class and how is it different from a regular class? An abstract class is an incomplete class that acts as a base class for other other classes to inherit from. An abstract class could be written this way:

    public abstract class MyAbstractClass
    {
        public abstract void GetTotal();
    }

And then a class that inherits from it could look like this:

    public class Tester : MyAbstractClass
    {
        public override void GetTotal()
        {

        }
    }

The Tester class is required to implement the GetTotal method otherwise an error will occur.

Abstract classes can contain methods, properties and events whereas interfaces only contain methods. Interfaces are useful because you can use them across multiple projects, in other words if you need to implement some functionality in your code from an outside source then you could use an interface to expose its methods.

  • Share/Bookmark
Tags:
posted by fr3dr1k in C# and have No Comments

C# Interfaces

Okay so what are interfaces and what makes them different from classes? Well an interface is like a contract for a class, that tell that class it must implement all the methods, properties, events and indexers of the named interface. Lets say you create a simple class and a simple interface like this:

class myTestClass : IMyTestInterface
{
       public myTestClass()
       {
       }
}
interface IMyTestInterface
{
        void DoMyFunction();
        void DoMySecondFunction();
}

You will get a compiler error, because MyTestClass is required to implement DoMyFunction and DoMySecond. So what are interfaces used for and what makes it better than just a regular class. Well for one, you can implement multiple interfaces, and as you may know C# does not support multiple inheritance. You can for example implement an interface from one or more other interfaces.

  • Share/Bookmark
Tags:
posted by fr3dr1k in C# and have No Comments
Get Adobe Flash playerPlugin by wpburn.com wordpress themes