When no longer working alone for all developers comes time to find some guidelines in writing code. Protocols and standards to allow "read" easily and intervene (more easily) in the code of others.
When we are working on a project more programmers, often of different languages, it is mandatory to find a common form of writing standards in internal and external documentation to your code. In my work I'm normally interact with:
- Objetive-C, C / C + +
- PHP
- HTML
- Javascript
- Actionscript
- CSS
More ...
I thought it might be useful to those who have recently approached the development of applications for Apple iPhone, compare Adobe ActionScript - the language used in Adobe Flash and Adobe Flex, more common among the neo-programmers - and Objective-C language used by Apple to develop its applications. Objective-C is in effect an object-oriented language in the pure sense, not that Actionscript is not, but Objective-C is definitely a plus because it is an extension of ANSI C and its syntax is a mix between C / C + + and Smalltalk, is a true OO (Object-oriented language).
More ...
From today inaugurated a new section (category to be corrected) dedicated to developing applications on Apple iPhone! I state now that many of the items that will be publishing a "cut" in line with the spirit of this blog, that will be mostly for advanced users. However, as I have done this in other topics, try to be as clear as possible and, where necessary, put some "basic concept" useful to a wider audience.
More ...
Who develops knows that one of the characteristics of functions ( function () ) is to have or not the input arguments. It can happen, sometimes you have to write a function that, based on input parameters, behaves differently (in OO programming this behavior are referred to as polymorphism). Variable parameters (varargs), already introduced at the time of the present by default in C and classical statement of the main :
1
| int main (int argc, char * argv []); |
More ...
I "revived" this article of mine wrote a bit 'of years ago. I slightly revised, updating a little bit here and there, but I think it is still relevant and interesting.
INTRODUCTION
What is a development language? A computer, aka PC (Personal Computer), has a personal language. This language is called machine code, to mean that every machine, so any computer (PC compatible, Apple, Unix, etc ...), it has a unique and proprietary. The programs that we see "run" on our PCs are mainly carried out by the mysterious object called a microprocessor. This represents the heart, the intelligent unit, of each electronic processor. In reality, an application is not executed by the microprocessor, but relies only, so to speak, in what is called operating system: a layer software from the manufacturer of the machine (see, for example, the Apple Macintosh).
More ...
It sounds obvious, but some escape the subtle difference between constants and variables in a programming language. The constants, from the name, do not change their value during the course of a program, while variables can do it! Often, however, happen to use variables instead of constants without realizing it, also because this will not impact the logic of an application. Despite this, the difference between constants and variables, and there emerges all at compile time, where the constant plays a ruole definitely more powerful.
Coming from C or Assembly programming knows the difference between constants and variables, especially because, both in Assembly and C, constants play a role by MACRO. For MACRO indendo a "piece of code" that is labeled and replaced in the code at compile time. The compiler, in short, performs a sort of find .. replace (and is sostituitsci) in the code each time it encounters a constant.
Imagine you write in the following simple C code fragment:
1 2 3 4
| 5 ; int a = 5; 3 ; int b = 3; int c; b ; c = a + b; |
sono indicate come variabili in questo caso. Both a that b are shown as variables in this case. In C, in fact, the constants are defined with the keyword #define . sono state definite come int . We note immediately that a which b has been defined as int . Already here you can make a first optimization. If we know that our variable a never exceed a certain value, you should declare it properly and do not use data types at random. Some developers do not bother to declare the correct types, thinking that this does not affect the performace! Wrong! Alternatively it is acceptable that the first draft of the Code does not involve this level of detail. However, a good rule, during the development process, review the code and check the data types.
However, in an assembly of the Motorola family, for example, as the mythical 68000, our code would seize completed (without optimizations) in a kind of:
1 2 3 4
| , d0 ; int a moves. the # 5, d0; int , d1 ; int b moves. the # 3, d1, int b d2 ; int c - foo moves. the d1, d2, int c - foo l d0 , d2 ; risultato in d2 ovvero c add. the d0, d2, d2, or result in c |
or:
1 2 3
| , d0 ; int a moves. the # 5, d0; int , d1 ; int b moves. the # 3, d1, int b d1 ; risultato in d1... moves. the d0, d1, d1 result in ... |
The compiler, however clever, effort in optimizations, then write the code with the right keyword can only help to improve the compiled output. In our case, if the value 5 is a constant is not convenient to use an integer variable, because the compiler, correctly, whereas the variable variable, precisely, a whole predisponde to contain the simple value of 5, which in binary is 101, ie occupies three simple bits (if anything, int is a 32bit or 53bit worst a double-precision floating point!). If we had written the code like this:
1 2 3 4 5
| # Define MIA_COSTANTE 5
3 ; int b = 3; int c; b ; c = MIA_COSTANTE + b; |
The compiler would know from the outset that MIA_COSTANTE , being constant, the value will not change so I can reserve less space to treat it. In practice the Assembly code diverebbe:
1 2 3
| d0 ; la "q" indica una istruzione "quick", cioè che tratta valori compresi tra -128 e +127 moveq # 3, d0, and the "q" indicates an instruction "quick", that is values between -128 and +127 ; An education "quick" takes less CPU time (4 clock cycles in this case) d0 ; anche qui uso una istruzione "quick" addq # 5, d0; here an instruction manual "quick" |
This code is extremely fast and takes up less bytes. What we must keep in mind is that when you declare a variable environment is ready to treat it as such, even if today's compilers can do miracles, performing a series of steps in the code before compiling (some compilers, even perform a kind of simulation program to optimize the compilation into machine code).
A good rule, therefore, is to declare the right kind for our variables, though these are. Alternatively use the constants, especially if the programming language we are using the expected (as in the case of the new Flash CS3).
More ...
Latest Comments
Giovambattista Fazioli : @ Nik: I'm happy! Good luck then!
Nik : I have Monday examining information on java, thanks to me you have been very useful, the book I was unclear ...
Mark : Thank you very much, I've lit
I solved it by setting [cc_objc] / / OptionViewController.m - ...
Giovambattista Fazioli : @ Mark: I suggest you think a more correct approach. If you run the subclass of the tab ...
louis : very clear and simple I have to admit that writing a pa hardly use delegates created by ...