10/08/2013

Objective-C Design Pattern

Please look at the http://www.oodesign.com/

Creational Patterns
*Abstract Factory
Creates an instance of several families of classes *
NSObject Objective-C class methods are sometimes call factory methods. This pattern is intrinsic to the Objective-C language. Every Objective C class is potentially an abstract factory. This pattern is also used to implement CocoaClassClustersSubClass">ShouldClassClusterPlaceholderBeASubClasshttp://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*Builder Separates object construction from its representation *
NSDocumentManager? � Builds NSDocument instances with NSWindowManager(s), handles recent documents menu, builds document related responder chain� NSApplication? � Builds main menu, initial responder chain, run loop�
*Factory Method Creates an instance of several derived classes *
Objective-C class methods are sometimes call factory methods. This pattern is intrinsic to the Objective-C language. NSObject ClassClustersSubClass">ShouldClassClusterPlaceholderBeASubClasshttp://developer.apple.com/documentation/Cocoa/Conceptual/MemoryMgmt/index.html
*Prototype A fully initialized instance to be copied or cloned *
NSCell is a Prototype when used with NSMatrix.
*Singleton A class of which only a single instance can exist *
SingletonDesignPattern SingletonAlternatives NSApplication NSNull NSFileManager NSWorkspace http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaObjects/Articles/CreateSingleton.html http://developer.apple.com/documentation/Cocoa/Conceptual/CocoaObjects/Articles/ObjectCreation.html
Structural Patterns
*Adapter Match interfaces of different classes *
http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*Bridge Separates an object�s interface from its implementation *
*Composite A tree structure of simple and composite objects *
http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.htmlWrappingIsBad
*Decorator Add responsibilities to objects dynamically *
http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*Facade A single class that represents an entire subsystem *
NSImage - NSText and NSTextView encapsulate the functionality of complex text layout and editing which is internally implement with NSTextStorage, NSLayoutManager, and other classes.
http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*Flyweight A fine-grained instance used for efficient sharing * NSCell
*Proxy An object representing another object *
http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
Behavioral Patterns
*Chain of Resp. A way of passing a request between a chain of objects *
http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*Command Encapsulate a command request as an object *
http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*Interpreter A way to include language elements in a program *
Value Transformers?
*Iterator Sequentially access the elements of a collection *
NSEnumerator http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*Mediator Defines simplified communication between classes *
NSObjectController, NSArrayController, NSTreeController, and NSUserDefaultsController http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*Memento Capture and restore an object's internal state *
NSCoder NSKeyedArchiver and NSKeyUnarchiver http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*Observer A way of notifying change to a number of classes *
NSNotificationCenterhttp://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*State Alter an object's behavior when its state changes *
*Strategy Encapsulates an algorithm inside a class *
NSLayoutMananger NSFormatter?
*TemplateMethod Defer the exact steps of an algorithm to a subclass *
http://developer.apple.com/documentation/Cocoa/Conceptual/DesignPatterns">CocoaDesignPatterns/index.html
*Visitor Defines a new operation to a class without change *
Cocoa Unique Patterns
*Target/Action A variation/simplification of the Command pattern *
NSControl NSActionCell @selector Similar to Qt Signals & Slots
*Method Swizzling A technique for runtime modification of the relationship between message selectors and the implementation that will be called in response to a message *
*Delegation Enable one object to control, modify, or specialize the behavior of another object through a loosely coupled interface.

PHP Job Interview Questions

PHP Design Patterns 

As a PHP contractor, consultant, and freelancer I've had a fair number of interviews - and sometimes I have been asked technical questions. Here are a few to help you prepare for your next PHP job interview.


=,==,=== - what is the difference between these?
= assigns a value, == checks if value is the same, === checks if value is the same and the variables are of the exact same type.


Echo, print, printf - what is the difference between these?
Print and echo both output what is passed to them. Print acts like a function, so you can use it in complex statements. Printf is used to format the output.


Include, include once, require - what is the difference between these?
Include will includes a file each time it is called. Include_once would only include a file one time, so if a php program has a file in two include_once statements only the first will be done. Requre is like include, but if the file included is not available a fatal error occurs and processing stops.


Are variables passed to functions by reference or value?
A variable is passed by value unless the variable is passed with an &, such as functionName(&$variableName)


How do you encrypt data?
The PHP crypt() function can be used to encrypt data. The PHP md5() function is very pretty widely used, but is a one way hash, and can not be decrypted. (Honestly, the one time I had this question I drew a complete blank, so I'm not exactly certain what they were looking for.)


What editor or ide do you use?
Interesting question, probably does say something about your programming capabilites. I use Eclipse with PHP extensions, and interviewers seem to like that. There are probably others such as Zend Studio that are also excellent answers. Serious Unix users would be good with vi or emacs.


PHP Statics, what are they and how do you use them?
As with Java, if the job is for OO PHP (that is PHP 5), there will be a question on PHP static variables. You may be asked how to reference a static from inside and outside of the class it is in, or just show that you get the basic concept of a variable or function that is for the whole class and not an instance.


Design Patterns general questions
Now we are really into OO stuff. As in java job interviews I've usually been asked about design patterns in fairly vague terms, such as "describe the design patterns used in the systems you have worked on". I was asked that so much that I drew out some UML to bring with me to interviews, as I found drawing up the UML during the interview to be distracting and slow.

Java Pattern / PHP Patterns

Please look at the http://www.oodesign.com/


Java Design Patterns

Abstract Factory == Sets of methods to make various objects.
Builder = Make and return one object various ways.
Factory Method = Methods to make and return components of one object various ways.
Prototype = Make new objects by cloning the objects which you set as prototypes.
Singleton = A class distributes the only instance of itself.
Adapter = A class extends another class, takes in an object, and makes the taken object behave like the extended class.
Bridge = An abstraction and implementation are in different class hierarchies.
Composite = Assemble groups of objects with the same signature.
Decorator = One class takes in another class, both of which extend the same abstract class, and adds functionality.
Facade =  One class has a method that performs a complex process calling several other classes.
Flyweight = The reusable and variable parts of a class are broken into two classes to save resources.
Proxy =  One class controls the creation of and access to objects in another class.
Chain Of Responsibility = A method called in one class can move up a hierarchy to find an object that can properly execute the method.
Command = An object encapsulates everything needed to execute a method in another object.
Interpreter = Define a macro language and syntax, parsing input into objects which perform the correct opertaions.
Iterator = One object can traverse the elements of another object.
Mediator = An object distributes communication between two or more objects.
Memento = One object stores another objects state.
Observer = An object notifies other object(s) if it changes.
State = An object appears to change its` class when the class it passes calls through to switches itself for a related class.
Strategy = An object controls which of a family of methods is called. Each method is in its` own class that extends a common base class.
Template = An abstract class defines various methods, and has one non-overridden method which calls the various methods.
Visitor = One or more related classes have the same method, which calls a method specific for themselves in another class.


PHP Design Patterns

Creational Patterns

Abstract Factory = Sets of methods to make various objects.
Builder = Make and return one object various ways.
Factory Method M= ethods to make and return components of one object various ways.
Prototype = Make new objects by cloning the objects which you set as prototypes.
Singleton = A class distributes the only instance of itself.

Structural Patterns

Adapter = A class extends another class, takes in an object, and makes the taken object behave like the extended class.
Bridge = An abstraction and implementation are in different class hierarchies.
Composite = Assemble groups of objects with the same signature.
Decorator = One class takes in another class, both of which extend the same abstract class, and adds functionality.
Facade = One class has a method that performs a complex process calling several other classes.
Flyweight = The reusable and variable parts of a class are broken into two classes to save resources.
Proxy = One class controls the creation of and access to objects in another class.

Behavorial Patterns

Chain Of Responsibility = A method called in one class can move up a hierarchy to find an object that can properly execute the method.
Command = An object encapsulates everything needed to execute a method in another object.
Interpreter = Define a macro language and syntax, parsing input into objects which perform the correct opertaions.
Iterator = One object can traverse the elements of another object.
Mediator = An object distributes communication between two or more objects.
Memento = One object stores another objects state.
Observer = An object notifies other object(s) if it changes.
State = An object appears to change its` class when the class it passes calls through to switches itself for a related class.
Strategy = An object controls which of a family of methods is called. Each method is in its` own class that extends a common base class.
Template =An abstract class defines various methods, and has one non-overridden method which calls the various methods.
Visitor = One or more related classes have the same method, which calls a method specific for themselves in another class.

QUARKUS & GraphQL

 QUARKUS & GraphQL https://www.geeksforgeeks.org/graphql-tutorial/ https://quarkus.io/guides/smallrye-graphql-client https://www.mastert...