Skip navigation

Sign up | Lost password? | Help

Hello World

Practical programming... and stuff...

Posts tagged with "programming"

What are the controller and model in MVC?

,

A lot of people seem to be slightly confused about what the M and C, Model and Controller, of MVC are, in regards to web applications.

  • What does the Model do?
  • What does the Controller do?


View is what everyone seems to know, though… I wonder why is that so? What is so confusing about Models and Controllers?

Read the rest of the post at codeutopia.net

The mythical HTTP protocol

,

The HTTP protocol is what powers todays web. While not useful for most people, knowing how HTTP works is important for those who work with dynamic web sites.

Still, it seems that the protocol is mostly a mystery to a lot of developers and some features of the protocol, such as the accept-language header, aren't really used.


Read the rest of the post at codeutopia.net

How to improve your JavaScript

,

There's a lot of resources on the internet related to coding JavaScript, but many of them are poor and out of date, which I believe is one of the reasons why a lot of people still can't manage to write JavaScript code which works in all major browsers (IE, Firefox, Opera and Safari - where possible to test it)

Let's check out some useful JavaScript resources to improve our skills, ranging from books to blogs and frameworks/libraries.

Read the rest of the post at codeutopia.net

MacGyver and programming

,

The other day I thought about using MacGyver as an example when talking about programming.
Why MacGyver?

In the TV series, he builds clever tools from common everyday things. I think this is why MacGyver is a very good programming analogy - in both good and bad.

Read more...

Singleton pattern vs Static classes

,

Why use Singleton over Static classes?
If you want a simple class that's accessible from everywhere in your code, you could easily use a static class to achieve this.

In PHP, you can use :: to access classes statically: MyClass::doSomething(), in C# you can declare a class static and so on. It's much simpler to create and access static classes than singleton classes, too.

The singleton does have some advantages though...

Read more...

Building a CMS with the Zend Framework

, ,

I've been working on a Content Management System (CMS) for my personal use and for experimenting. Since I like the Zend Framework so much, using it as a base for the CMS was a natural choice.

While at first it might seem that using ZF adds many restrictions, it actually isn't like that. Thanks to the modularity of the framework, you can easily replace certain functinality with classes of your own to change the way it works.

There are also many other things to consider when making a CMS.

Read more...

What kind of a programming language would you design?

,

What's your dream programming language like?

I'm sure all of us who program, and maybe even some who don't, have wanted to change some thing in a language.

What kind of a programming language would you design, if you could just decide the awesome features for the language and have a team of top programmers implement it for you? Well, you could of course do it yourself too if you wanted... :wink:

Feel free to pitch in even if you're not a programmer

Read more...

Exceptions or Error codes?

,

You usually have two choices when you want to return errors from your functions:

Exceptions and error codes.

Exceptions are the OOP way of doing things: You throw a new exception, where the exception is a new instance of some exception class.
Error codes are "oldschool": They are just values returned from the function, but with special meanings.

But which one is a better choice and why?

Read more...

Globals are evil

, ,

Globals are evil - do not use them. Quoting Martin Fowler,

remember that any global data is always guilty until proven innocent.



What is a global? A global is a variable that is accessible from anywhere in an application. For example, in PHP declaring any variable outside a function/class method will make it global.

But what about when I want to have some data globally available in my application?
One useful solution is to use the singleton pattern to create a storage class or something like that. We'll look at that later in this post.

Read more...

Verbose programming

Do you use variable names like $a, $b or maybe $foo or $bar in your code?

Stop using them, it's bad practice.


I've used similar variable names such as those for a long time myself, but I've been moving away from them for a while now.

But why is it bad?

Read more...