Archive

Archive for the ‘Programming’ Category

What is MVC Architecture? (Model – View – Controller)

April 19th, 2009 71 comments

MVC Architecture has implemented by Trygve Reenskaug at 1979 for the first time. It was implemented on Smalltalk at Xerox labs. Then benefits and advantages of this architecture has been accepted by most of the coders and software engineers.

It was an information about MVC’s history above. Now lets talk about what really MVC is. What do you understand from MVC. The word M stands for Model, V stands for View and C stands for Controller. I am going to mention about each item.

The figure above may help you while thinking what structure it might have. Let’s start with Model.

Model:
It handles data processing and database works part. Model processes events sent by controller. After processing these events then it sends processed data to controller (thus, controller may reprocess it) or directly to view side.

View:
View prepares an interface to show to the user. Controller or model tells view what to show to the user. Also view handles requests from user and informs controller.

Read more…

VN:F [1.9.22_1171]
Rating: 8.4/10 (501 votes cast)
VN:F [1.9.22_1171]
Rating: +172 (from 204 votes)
Categories: General, Programming Tags: , , ,

What is PHP?

April 18th, 2009 No comments

First of all i need to say that PHP is a language which you are going to in love with. (That is of course if you are a developer ) PHP stands for PHP: Hypertext Processsor.

To start with it you should have knowledge about basic scripting and HTML language.

PHP is totaly free to use and download that is because it is an open source. Well there are many scripting languages on the earth. PHP is server-side scripting language. It means codes are executing on the server-side not in the client-side.

Thus, clients cannot see your php script, a client can only see pure html content. Now i can say PHP is secure langauge since user cannot see your PHP code. How it works? For instance, a client (user) requests a webpage from your server. Then your server executes php code and returns pure html content to the user. And user have no chance to see what is going on at the server-side.

Extensions : .php, .php3, .phtml

Read more…

VN:F [1.9.22_1171]
Rating: 7.5/10 (6 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Categories: PHP, Programming Tags: , ,

Let’s get started with jQuery

February 27th, 2009 No comments

Nowadays you may see tons of Javascript frameworks coming up. The truth is that it makes your code efficient if a framework used instead of pure javascript code. Most of the javascript frameworks helps you to solve crossbrowser difficulties. Probably you heard about Prototype and MooTools. You may see some people are trying to decide between these frameworks. I should say i am fan of jQuery. jQuery comes with tons of futures and flexibility and you can do a big work with less effort and it is not just a regular library however jQuery is even ajax and effect library. It does evertything i need with piece of code.

jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, event handling, animating, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript.

Let’s say you are using some other libraries as well, there it goes, jQuery is such a good friend with other libraries. API designed with conciseness and convenience as the driving factors.

Before start with jQuery i want you to know some basics about it. You can download the framework basically from www.jquery.com then download it on your desktop. This is how jQuery places in html code.

<html>
<head>
<strong><script type="text/javascript" src="jquery.js"></script></strong>
<script type="text/javascript">
<strong>// Your code goes here</strong>
</script>
</head>
<body>
<a href="http://jquery.com/">jQuery</a>
</body>
</html>

You can start with placing your core *.js file which is jquery.js for this example.

Read more…

VN:F [1.9.22_1171]
Rating: 4.0/10 (6 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)
Categories: General, Jquery, PHP, Programming Tags: , , ,

Embed php into Javascript

February 24th, 2009 No comments

In javascript you cannot read variables from a server instanly however if you embed your php code you may pass variables into javascript code.

So php can pass its variables when page loads. Here is an example using jquery

< ?php $variable = 'Here is value'; ?>
<script type= "text/javascript">
$(document).ready(function(){
var button = < ?php echo $variable; ?> ;
});
</script>

Read more…

VN:F [1.9.22_1171]
Rating: 3.8/10 (6 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)

Example Code #4 – Intersect and Write in Prolog

January 1st, 2009 1 comment

1- “!” character stops the query when it is false and “;” runs as “or” so it skips the false part then moves next part

smaller(X,Y):- X
X>Y,write(Y),write(' is bigger then '),write(X),!;
write('They are equal').

Query -> ?smaller(3,5) : 3 is smaller then 5
Query -> ?smaller(8,5) : 8 is bigger then 5
Query -> ?smaller(5,5) : They are equal

2- Intersect relation

Intersect function uses an external function inside. Member function checks whether the first parameter is member of the given list or not.

Query -> member(3,[3,4,5]).

member(HM,[HM|TM]).
member(XM,[HM|TM]):- member(XM,TM).

and the intersect function gives you the result on LI variable. Try it.

intersect([ ],LI,[ ]).
intersect([HI|TI],LI,LI2):- member(HI,LI),intersect(TI,LI,LI3),LI2=[HI|LI3],!;intersect(TI,LI,LI2).

Query -> intersect([3,4],LI,[4,5]) : [4]

VN:F [1.9.22_1171]
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.22_1171]
Rating: 0 (from 0 votes)