Tuesday, September 30, 2008

Digital Playground Watch Movies Online

Design Patterns - Decorator

go back to school after a summer fooling around is never easy, but then you have to do. And Skep, recently joined the team sick, came from vacation with a new idea for his rts: he wants to make the units available to the player can be divided into teams , but does not want to be a simple grouping. He wants to ensure that the user is prompted to create a team through the group because you can cover the defects of a unit with the merits of another, so that the ability of an individual to become the skills of all: a doctor within the group, for example, means that all the soldiers learn to care slightly . In addition, each group thus created would be fun to assign a value of force that affects the outcome of the battle group. In this way create more homogeneous groups can make easy to overcome certain special missions.

The first idea was a simple array of soldiers as the data field of a new class CombatGroup. The idea has proved fallacious (!!!): suffered in this way, the code would prove difficult to modify and extend in case of updates, what would happen if we wanted to create groups of different type, such as an assault group and a group of spare drive? The second idea

jumped nell'insana mind of our young has been to exploit in a massive inheritance. His thought is to create subclasses of CombatGroup depending on the purpose of the team and add them to the soldiers one at a time. His idea is summed up in the following format



Even though this design provides a point in the hierarchy there is a list of some kind of soldiers in the team. Such a list provides methods to insert and remove elements and know that in the event of changes to the characteristics of a group would need to go to these methods also change.

The idea that comes to our aid is as simple as powerful and difficult to apply
keep classes open to extension but closed to changes
E 'must always design our hierarchies so that are easily extendable but what extend should not be changed by the extension. What

second Skep completely solve the problem of maintaining a list of participating members of the team is a completely different approach. You can consider an item as a team of one-component? Sure, why not. Would it be possible then add more as teams made just told to form groups of several elements? It would make sense. In this way, you could probably use inheritance in an almost recursive and get the results of strength team and list of components without any list of items!

Helping our friends get funny as usual a design pattern, that the most friends call Decorator. The cold definition says
Decorator adds responsibility to an object dynamically. Also provides a flexible alternative to the extension to extend the functionality

Let's see how to solve the problem points:

1. Create a group such as a AssaultGroup , initially empty
2. "Decorate" the group with a Soldier. Now the group contains an element.
3. "Decorate" the group with an Engineer.
4. To obtain the components GetComponents call () and let us consider the delegation to get the components. We do the same thing for the strength of the group.

How does, however, the delegation of the methods? We can think for one second to the group as a room.
At the room is completely empty, waiting to be decorated. Clearly the method calls GetComponents () and getGroupPower () give null result as if a hypothetical question was to ask these questions to the room would not receive response.



were decorated with an element, the room is filled with a person who sits at the door, so that if someone steps in to ask how many people are there and how strong is the group, she can answer on behalf group.

Each time the room is "decorated" by a new person, the line scale and the newest is at the door ready to provide the information if requested, also on behalf of the entire group.

To know how strong is the group for example, can certainly not scream "how strong are we?" aloud all respond and be forced to do the sums of all. This would give a unit a special ability that has no sense. (Suppose I am chief, who just are not able to count would be a casino). You might instead ask how strong is the last to communicate what is in the row in front of him, which adds value to its power and communicate in turn to the front. So that the door should not do is add the value that has come to own and communicate, just as they did everyone else. Such a thing is feasible to get a list of the group's capacity.





Once you understand the mechanism, we see how to create a schedule of classes for instantiating the decorator pattern for our case.




The focal point for understanding this design pattern is that objects and decorators are in the same hierarchy as the decorators are lower can be taken and used as components were real . Even if we use inheritance does not go against the principle of preferring the composition because agggiungiamo behavior to a group through the composition of objects: the genius is that all objects are of this subtype composition of the compound, could therefore be used in its stead. In addition, we untied from the static inheritance could add new behaviors at runtime.

Let 'code now. Today I take the good C + + instead of java, even if I put in the key interface (professionalism at historic lows), which clearly will implement an abstract class. We start with classes and CombatGroup AssaultGroup, presenting an implementation quite Natural

 
class CombatGroup
{public:
CombatGroup ();
virtual GetComponents List ();
getGroupPower virtual int ();
/ / ...
}

AssaultGroup class: public CombatGroup
{private: int
_initialPower;
public: virtual int
getGroupPower ();
virtual GetComponents List ();
//...
}


Take for example the method getGroupPower. Its implementation at this level is this. We do not care for any decoration in the future, give back only what we know directly, or the initial strength.

 
int AssaultGroup: getGroupPower () {return
_initialPower;}



At this point we can move to codify the decorations. We have another abstract class that generalizes the decorators. It contains a reference to the decorated component to it, so that the delegation would go up the chain (as in the above example the value of passive force until the last item in the first row).

 
GroupDecorator class: public CombatGroup
{private:
CombatGroup _group;
public:
GroupDecorator (CombatGroup *);
virtual GetComponents List ();
getGruopPower virtual int ();
//...
}

List GroupDecorator::getComponents() {
_group.getComponents();
}

int GroupDecorator::getGroupPower() {
_group.getGroupPower();
}


Ora passiamo alle decorazioni vere e proprie. Anche in questo caso l'implementazione del metodo getGroupPower non fa altro che sommare la forza particolare dell'unità a quella dell'intero gruppo. Questo è proprio il principio di delegazione delle responsabilità di cui parlavo prima.

  
class SoldierDecorator : public GroupDecorator {
private :
// unit rappresenta the drive that goes to join the group. This class is a container
/ / for it
Unit _unit;
int _power;
public:
SoldierDecorator (CombatGroup *);
getGroupPower virtual int ();
virstual GetComponents List ();}



/ / IMPLEMENTATION NOTE! Int
SoldierDecorator: getGroupPower () {return
this._power _group.getGroupPower + ();}



This has always seemed quite unsubstantiated until I figured out how to make the whole operation. How do I create a group then? Here's the solution

 
/ / create a group CO 2 soldiers, an engineer and a doctor
CombatGroup aGroup AssaultGroup = new ();
aGroup = new SoldierDecorator (aGroup)
aGroup = new SoldierDecorator (aGroup)
aGroup = new EngineerDecorator (aGroup)
aGroup = new MedicDecorator (aGroup)

aGroup.getGroupPower ();


Ok, now the pattern is complete. Decorator is extremely powerful and quite difficult to understand, since the idea of \u200b\u200bthe composition over inheritance is not intuitive at all from my point of view. In many cases it is preferred that a similar pattern we have already analyzed, namely the strategy. There are certainly similarities between the two, as they both add something to run in an orderly and flexible. The difference is in what to add: decorator is used to add behavior in terms of construction, or change the internal organs of an object and thus its capacity. Strategy deals rather closely the behavior as such, changing the "habits" of an object without touching the inside.

Decorator still has some major disadvantages:
- Although it is possible to dynamically add coportamento runtime, it can be removed without changing the nature of the object . This is in many cases it may be pointed out fatal. Moreover decorator is spesso usato nello sviluppo di interfacce grafiche, per aggiungere particolari quali bordi a componenti grafiche, quindi cose che non vengono mai più rimosse.
- Da un punto di vista di identità un componente e un decoratore non sono per niente la stessa cosa ma vengono trattati come se lo fossero . Questo punto, che è il senso proprio del pattern, è anche il suo difetto logico più vistoso.
- E' importante che le classi in cima alla gerarchia siano leggere, in quanto è necessario nei sottotipi assicurare la conformità delle interfacce è programmare classi decoratore con troppi metodi provoca una probabilità maggiore di errori.
- Decorator sfruttato in un progetto di grandi dimensioni può rivelarsi detrimental to the maintenance because it causes the generation of a large amount of very small classes. But of course it helps a lot the work of the designer.

Great Skep, again failed to find a way to keep me awake a few nights!

How Long Does It Take To Get Stds Testing Results

Qt XCode &

In this short guide explains how you can work with XCode and the Qt libraries. First, after choosing the project name (NP), we create a new folder and name checks as a NP.
Inside the folder create an empty file, for convenience may be called main.cpp. Then open a terminal, we move into the newly created folder and type : qmake -project e qmake.
All’interno della cartella si creerà il progetto XCode con il nome NP. Ora non ci resta che provare a scrivere il codice cullati dall’autocompletamento e tutti i favolosi servizi che offre XCode. Ecco un esempio di Hello World :

  
#include "QApplication"
#include "QPushButton"

int main(int argc, char * argv[])
{
QApplication app(argc, argv);

QPushButton * b = new QPushButton("Ciao Mondo");

b->show();

return app.exec();
}

Premete Build and Go e se tutto funziona siete pronti per lavorare con le Qt e XCode.

Wednesday, September 24, 2008

Distance Hanging Rod From Wall

Cooliris: the 3D web

As a first post I wanted to publish some information "useless" but of style, something cool and feel. So I started wandering around the web for hours until they gave me the right information.
Cooliris is the one for me!



This add-on for Firefox and Safari lets you view images, video and multimedia content to many different sites, feeds and other information. Already today there are several possible sites that work with famous cooliris as:
- google
- amazon
- Flickr
-
myspace - youtube ...

cooliris But what can and what??
Once you've installed the plugin and pushed the button lo schermo si oscura e tutti i contenuti multimediali sono visualizzati in full-screen 3D. Attraverso l'uso del mouse e della tastiera ci si può muovere tra i contenuti, visualizzare foto, video... il tutto in maniera semplice, intuitiva e veloce.
In aggiunta è possibile inviare tramite mail quello che si sta visualizzando, leggere news con Discover ed acquistare - o confrontare prezzi e prodotti - su Amazon.

Lo si può scaricare in maniera gratuita dal sito del produttore
www.cooliris.com
dove si trova anche un video che spiega velocemente e semplicemente tutte le sue potenzialità.

Insomma, buon cooliris a tutti!

Wednesday, September 17, 2008

Whatpaper Towel Brand Is The Strongest

icons to applications starting with XCode generated

If we were to assign a nice icon in our program created with XCode , but we did not have a picture. Icns , the format used by Apple for icons, we must not despair, look for a program that carries out the conversion. This program comes with Apple's Tool the DVD to install the operating system or freely downloadable from the Apple website. The program is called Icon Composer and we can find inside the folder Developer / Applications / Utilities . Once opened , just sempicemente move over the image to be processed, which will create icons in different sizes atumatico, doc.number menu "File" "Export" and GOCO's it.
To add it to your XCode project, move the file. Icns just created in the root folder of the project, open XCode, premre twice on the active target for compiling, check the item "Icon File" and enter the file name. Icns . XCode will seek to create within the file. App generated Resurce a folder with the image and the file. App selazionata will be represented by the icon.

Chevy Silverado With Rockstar Rims

wxWidgets XCode

Here you will learn how to install wxWidgets into a Mac and how to configure XCode in order to have the auto-completion for wx and the ability to compile programs written with this library.
First you need to download the sources from: http://www.wxwidgets.org/downloads/ and downloading sources wxMac. Once downloaded, unzip to a directory you like, go to the src folder and you will find an XCode project, open it and compile it in a few minutes you have installed wxWidgets libraries. To do a check just open a terminal and type wx-config - version that will return the version of wx installed.
Well now we're ready to write our first program.
Open XCode:
  • create a new empty project "Empty Project", enter the name and specify the folder and press "Finish".
  • menu, select "Project" and then "New Target ..." from the section in bold "Carbon" select "Application" and press "next", specify the name and press "Finish"
  • close the window that has just opened for editing Target, from "File" menu choose "New File ..." menu and bold "C and C + +" select "C + + File" and press “Next”, inserire il nome e premere “Finish”
  • dal menu premere “Project” e “Edit Active Target “nome target”, spostarsi nella linguetta “build”
  • aprire una console e digitare wx-config --cxxflags, copiare uno a uno tutti i path che iniziano per -I senza il -I e incollarli nella voce “Header Search Paths” nell'editor del target
  • dalla console selezionare tutte le voci precedute da -D con -D compreso questa volta e copiarle nella sezione “Other C Flags”
  • tornare alla console e digitarre “wx-config --libs”, copiare tutto il contenuto e incollarlo nella sezione “Other Linker Flags”
  • infine ricercare la voce “ZeroLink” e togliere del tutto la selezione
Fatto questo dovremmo essere pronti per scrivere un programma con la comodità dell’auto completamento e le funzionalità specifiche di XCode per scrivere programmi per il Mac.
Per essere sicuri che tutto funzioni scriviamo l’Hello Word, nel file .h:
  
#include "wx/wx.h"

class HelloWorld : public wxApp {
virtual bool OnInit();
};

IMPLEMENT_APP(HelloWorld)

nel file .cpp :
  
bool HelloWorld::OnInit()

{wxFrame * f = new wxFrame (NULL, -1, WXT ("Hello world"));
f-> Show (true);
return true;}


press Build and Run and you should see a beautiful window that says Hello World.