Lessons on programming

Here is going be some links to posts that I have done regarding different aspects of programming in different languages so that it brings it all together as such. For example, what is a class and how does it work etc. anyway here are some basic tutorials and links to different languages and kinder to show how they are kinder all linked :). The different headings will have different languages links underneath ;)..

Introduction to

Hello world

The classic hello world program examples for some programming languages.

  1. Flex – Hello world (flash swf)
  2. Javascript – Hello world
  3. PHP – Hello world.
  4. Ruby – hello world.
  5. C++ – Hello world
  6. C# – hello world.
  7. Java – hello world.

Variable types

  1. Java – local variables

Casting of variables

  1. Reinterpret_cast – c++
  2. const_cast – c++
  3. dynamic_cast – c++
  4. static_cast – c++

Flow control (loops) – while / for / foreach etc.

Arrays

  1. Java

Methods

  1. Java – add two numbers
  2. Ruby – add two numbers
  3. PHP – add two numbers
  4. C# – add two numbers
  5. Javascript – add two numbers
  6. C++ – add two numbers

Classes

  1. Java

Comparison of classes

  1. Java – Equals / Compare
  2. C# – Equals

Delegates / Events

  1. C# – Delegates
  2. C# – Events

Interfaces

    Java

Overloading

Overloading is when you overload a methods/functions within a class, when you overload a method you can define a function with the same function name but have either different return values and passing parameters.

  1. C#

Overriding

Overriding functions allow for derived classes to override virtual functions from the base class.

  1. C#

Polymorphism

Polymorphism allows for a base class to be inherited to create a new class that implements/add’s new functions. Here are some examples in different languages

  1. C++
  2. PHP

Templates and Generics

Templates and Generics allow for the same class to be initialized with different data types. Here are some examples in different langauges

  1. C++ (Templates)
  2. C# (Generics)
  3. Java (Generics)

Constants, properties, fields, methods.

const in c++ ( and also within functions definitions) can be found here

Shall add more when doing the tutorials links

Files

  1. Java – read/write

Exercises

During a interview I was asked to do some “home work” coding to show my style of coding and if I was able to do the tasks.

  1. Exercise 1. (Simple)
    Accept form input for a user registration form, and store results in a MySQL table, using PHP. Applicant should demonstrate a knowledge of input validation, and using server-side code to avoid sql injection exploits. The user data should include first name, last name, email, and phone number.

    Usage of Javascript pre-validation would be a plus, as would forward planning, i.e. adding a unique code to the user details that could be used to validate their email address. Suitable MySQL table schema should be demonstrated.

  2. Exercise 2. (Medium) –
    Write a class containing 2 functions. One function to merge 2 or more images into a single binary file. Write a counterpart function to this,which can extract the original files from the single binary, and write them out as single images, using their original filenames. Compression is not necessary, as the exercise is only designed to show an understanding of using binary files with PHP, filesystem error handling, and planning a simple file format.
  3. Exercise 3. (Moderately difficult)
    Create a simple stack-based calculator. This should be capable of performing addition, subtraction, multiplication and division. Example input would be: “2*(3+1)”. The result should be expressed as a numeric value, so the example should return 8. Usage of the eval() function, although amusing, is not allowed! This test is designed to show general programming skills, rather than an understanding of the programming platform; however the solution should be demonstrated using php as the language.

Leave a Reply

Your email address will not be published. Required fields are marked *