Metaobject Protocol

--Originally published at diegotc2016

According to Wikipedia the metaobject protocol provides the vocabulary to access and manipulate the structure and behavior of objects.

The main functions of the MOP are:

  • Creating and deleting new clases
  • Creating new methods and properties
  • Changing the structure of clases so that clases can inhert from other classes
  • Make or modify code for defining methods of a class

The MOP allows a system to modify the internal structure of objects.

I investigated more about the MOP and there’s a book about it which is called the Art of the Metaobject Protocol.

Metaobject Protocol

I got these information out of:

https://en.wikipedia.org/wiki/Metaobject

 


Metaobject Protocol

Preparing for partial 2 “exam”

--Originally published at miguelmzbi

Well, here I am… doing stuff, I want to sleep, but whatever, who needs that?

I do… I really should…

Here we go:

What are inheritance and polymorphism? (Specification and implementation)

  • Inheritance: When I think of inheritance, I think of the keyword “extends”, you know, that thing you put at the new class, when you want it to have all of the superior classes methods and attributes. That is inheritance.
  • Polymorphism: Now, this gets more complicated. It is to inherit a method from a superclass, but only to mostly have it modified in the subclass or in the same class (Overloading and overwriting).

What are overloading and overwriting? How do we implement those in Java?

  • Overriding: It is dynamic because its made between a hierarchy of classes. It implies that the method in the current class is the one being initialized (even if super classes have the same named method). The only way to get the supermethod also initialized is to write super.methodname().
    class Car { makeNoise(System.out.println(“Bruum”))}
    subclass Ferrari { makeNoise(System.out.println(“Big lousy bruum”))}
    Final output: Big lousy broom
  • Overloading: It is static because it can be done in the same class. It ocurrs when two or more methods have the same name, but different arguments (Type or quantity).

What is delegation?

  • To call another method, or even another class to do your chores (Instead of doing it by itself).

What are CRC cards and how do we use them?

  • Stands form Class Responsibility Colaboration. Used to stated how classes work. Its a design that answer to what and with whom the job will get done.

What do you feel are the benefits to object-oriented programming?

  • It provides the tools to create everything! Seriously. As always, if you consider that everything is an object, that means that, to some extent, you can create anything as long as it has characteristics and functions. If it isn’t sufficient to you, because you want still something more specific, you can overwrite and overload until you get exactly what you want.

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?

  • I really like the way my dear friend Arturo explained it. I guess I would explaine it as he has done it (The analogy with math dimensions -Luzma’s 4th dimension is really hard- its nice. And also, today I saw Interstellar, so he should add the 5th dimension to his explanation).
    The most difficult for anyone I guess it is the change from simple straight code to a more complex context. In OOP there is no room for code without order. You have a class, with a constructor, several methods, and a main method if needed. Then you have the arena (As defined here) were the objects are created with the required characteristics and do the required stuff. And then you have other classes that contain other objects and you need to find a way to get everything connected without making Java explode, or yourself.

Like a dear YouTuber would say (Jake Roper Vsauce3’s host). I gees I’ll stick to this until I have a proper way to end my posts:

“But remember my dear friend: Its not good-bye, oh no, its never good-bye, its… see you later (you’re pretty darn awesome)

-Miguel

 

 


Preparing for partial 2 “exam”

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?

--Originally published at diegotc2016

First of all I think changing to OOP was difficult because  I’ve learned this way of programming in a new language which is Java and this programming language has more difficult syntax than python has, most of beginners of programming use a simple language like python.

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?

The next thing I think has made OOP difficult is the proccess in order to code. I was used to code and just code without any paper proccess before coding. For programming in an object oriented way first you have to design the clases and these goes without any coding process, you are even told that you have to do the design process in paper and not just in an electronic tool.

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?

And the last thing that makes OOP a little bit difficult is the new concepts. This new concepts include class, method, encapsulation, inheritance, polymorphism. The new concepts may be difficult to understand if you have only worked with variables, lists, conditionals and just in a beginner way of programming.

Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?


Why do you think your change to object-oriented programming is difficult or what makes it difficult for the standard student?

What do you feel are the benefits to object-oriented programming?

--Originally published at diegotc2016

According to c4learn.com these are the advantages of OOP:

  • OOP provides a clear modular structure for programs.
  • It is good for defining abstract data types.
  • Implementation details are hidden from other modules and other modules has a clearly defined interface.
  • It is easy to maintain and modify existing code as new objects can be created with small differences to existing ones.
  • objects, methods, instance, message passing, inheritance are some important properties provided by these particular languages
  • encapsulation, polymorphism, abstraction are also counts in these fundamentals of programming language.
  • It implements real life scenario.
  • In OOP, programmer not only defines data types but also deals with operations applied for data structures.
  • Large programs are very difficult to write. Object Oriented Programs force designers to go through an extensive planning phase, which makes for better designs with less flaws

What do you feel are the benefits to object-oriented programming?

I got this out of:

Advantages And Features Of Object Oriented Programming

https://www.cs.drexel.edu/~introcs/Fa15/notes/06.1_OOP/Advantages.html?CurrentSlide=3


What do you feel are the benefits to object-oriented programming?

What do you feel are the benefits to object-oriented programming?

--Originally published at diegotc2016

According to c4learn.com these are the advantages of OOP:

  • OOP provides a clear modular structure for programs.
  • It is good for defining abstract data types.
  • Implementation details are hidden from other modules and other modules has a clearly defined interface.
  • It is easy to maintain and modify existing code as new objects can be created with small differences to existing ones.
  • objects, methods, instance, message passing, inheritance are some important properties provided by these particular languages
  • encapsulation, polymorphism, abstraction are also counts in these fundamentals of programming language.
  • It implements real life scenario.
  • In OOP, programmer not only defines data types but also deals with operations applied for data structures.
  • Large programs are very difficult to write. Object Oriented Programs force designers to go through an extensive planning phase, which makes for better designs with less flaws

What do you feel are the benefits to object-oriented programming?

I got this out of:

Advantages And Features Of Object Oriented Programming

https://www.cs.drexel.edu/~introcs/Fa15/notes/06.1_OOP/Advantages.html?CurrentSlide=3


What do you feel are the benefits to object-oriented programming?

What are overloading and overriding? How do we implement those in Java?

--Originally published at diegotc2016

 

Overloading: two methods are overloaded if  both methods have the same name but different argument types.

For example:

class DisplayOverloading
{
    public void disp(char c)
    {
         System.out.println(c);
    }
    public void disp(char c, int num)  
    {
         System.out.println(c + " "+num);
    }
}
class Sample
{
   public static void main(String args[])
   {
       DisplayOverloading obj = new DisplayOverloading();
       obj.disp('a');
       obj.disp('a',10);
   }
}

The output would be:

a
a 10

Overriding: is when someone declares a method in subclass which is already present in parent class.

For example:

class Human{
   public void eat()
   {
      System.out.println("Human is eating");
   }
}
class Boy extends Human{
   public void eat(){
      System.out.println("Boy is eating");
   }
   public static void main( String args[]) {
      Boy obj = new Boy();
      obj.eat();
   }
}

The output would be:

Boy is eating

What are overloading and overriding? How do we implement those in Java?

I got this information out of:

Method Overloading in Java with examples

Method overriding in java with example

http://javarevisited.blogspot.mx/2011/12/method-overloading-vs-method-overriding.html

What are overloading and overriding? How do we implement those in Java?


What are overloading and overriding? How do we implement those in Java?

What are overloading and overriding? How do we implement those in Java?

--Originally published at diegotc2016

 

Overloading: two methods are overloaded if  both methods have the same name but different argument types.

For example:

class DisplayOverloading
{
    public void disp(char c)
    {
         System.out.println(c);
    }
    public void disp(char c, int num)  
    {
         System.out.println(c + " "+num);
    }
}
class Sample
{
   public static void main(String args[])
   {
       DisplayOverloading obj = new DisplayOverloading();
       obj.disp('a');
       obj.disp('a',10);
   }
}

The output would be:

a
a 10

Overriding: is when someone declares a method in subclass which is already present in parent class.

For example:

class Human{
   public void eat()
   {
      System.out.println("Human is eating");
   }
}
class Boy extends Human{
   public void eat(){
      System.out.println("Boy is eating");
   }
   public static void main( String args[]) {
      Boy obj = new Boy();
      obj.eat();
   }
}

The output would be:

Boy is eating

What are overloading and overriding? How do we implement those in Java?

I got this information out of:

Method Overloading in Java with examples

Method overriding in java with example

http://javarevisited.blogspot.mx/2011/12/method-overloading-vs-method-overriding.html

What are overloading and overriding? How do we implement those in Java?


What are overloading and overriding? How do we implement those in Java?

Delegation

--Originally published at diegotc2016

Delegation is when a class “delegates” another class to do something.

Delegate is to give the power you have to do something to another person in order to do something.

In OOP delegation is when a class gives one or more functionalities to another class in order to do something.

Here’s an example:

Some parents want to go out. They hire a babysitter and tell her to look after the baby.
But what if the baby gets sick?
There’s a note on the fridge door. “In case of emergency phone Helen 555-3141”

This is a pretty good analogy for delegation. Helen is the
delegate.

//within the parent class
babysitter.delegate = helen
[babysitter lookAfter:baby]

//within the babysitter class
if (baby.isSick)
{
[delegate callAbout:baby]
}

When assigning actions to an object, you can provide that object with a delegate. The delegate will be called when the object needs to inform something or do something beyond the scope of the object.

Delegation

Where I got this information from?

http://es.thefreedictionary.com/delegar

https://www.quora.com/What-is-delegation-in-object-oriented-programming

https://es.wikipedia.org/wiki/Delegaci%C3%B3n_(inform%C3%A1tica)

 


Delegation

Domain Modeling (Modeling the App)

--Originally published at diegotc2016

What are the things in the application that we need to be aware of?

Identifying the Classes

We will use the scenarios in order to identify the objects, you can highlight the main classes that are written in the use story. For example:

Scenario: The coach gets into the “Sports Statistics and Performance Improvement” either in his laptop or in a mobile phone. Then the coach selects the sport he wants to evaluate, afterwards the coach types the name of the athlete and the computer will ask for the height, weight, % muscle, % fat, gym performance and sport performance of the athlete. The program will automaticlly display a gym routine based on great nutriologists, a gym routine based on excellent trainers and sport tips for the athlete based on outstanding athletes. If the athlete works well he/she will improve for his/her team

Don’t worry if you miss one or more objects, this is just the begining

Identifying Class Relationships

Taking it back to the last post I’ve made, I got this image.

Domain Modeling (Modeling the App)

The relationships are simply the arrows and it says for example, that if wine was consumed they must pay for wine

Identifying Class Responsabilities

You should highlight again the verbs of the classes. I can show you this point by taking again this example:

Scenario: The coach gets into the “Sports Statistics and Performance Improvement” either in his laptop or in a mobile phone. Then the coach selects the sport he wants to evaluate, afterwards the coach types the name of the athlete and the computer will ask for the height, weight, % muscle, % fat, gym performance and sport performance of the athlete. The program will automaticlly display a gym routine based on great nutriologists, a gym routine based on excellent trainers and sport tips for the athlete based on outstanding athletes. If the athlete works well he/she will improve for his/her team

Always remember that a custmer must be responsible by itself and it can also be responible for other objects. There can be a lot of responsabilities for one simple class.

Using CRC Cards

First of all CRC stands for Class Responsability Collaborators, its main objective is to order the classes. Each card is for one class. A CRC card is written as it follows.

Class Name

Responsabilities Collaborators

A CRC card must be written in paper and not in a digital way because by writing it in paper it makes you more concise and you kind of remember better when you write.


Domain Modeling (Modeling the App)

Domain Modeling (Modeling the App)

--Originally published at diegotc2016

What are the things in the application that we need to be aware of?

Identifying the Classes

We will use the scenarios in order to identify the objects, you can highlight the main classes that are written in the use story. For example:

Scenario: The coach gets into the “Sports Statistics and Performance Improvement” either in his laptop or in a mobile phone. Then the coach selects the sport he wants to evaluate, afterwards the coach types the name of the athlete and the computer will ask for the height, weight, % muscle, % fat, gym performance and sport performance of the athlete. The program will automaticlly display a gym routine based on great nutriologists, a gym routine based on excellent trainers and sport tips for the athlete based on outstanding athletes. If the athlete works well he/she will improve for his/her team

Don’t worry if you miss one or more objects, this is just the begining

Identifying Class Relationships

Taking it back to the last post I’ve made, I got this image.

Domain Modeling (Modeling the App)

The relationships are simply the arrows and it says for example, that if wine was consumed they must pay for wine

Identifying Class Responsabilities

You should highlight again the verbs of the classes. I can show you this point by taking again this example:

Scenario: The coach gets into the “Sports Statistics and Performance Improvement” either in his laptop or in a mobile phone. Then the coach selects the sport he wants to evaluate, afterwards the coach types the name of the athlete and the computer will ask for the height, weight, % muscle, % fat, gym performance and sport performance of the athlete. The program will automaticlly display a gym routine based on great nutriologists, a gym routine based on excellent trainers and sport tips for the athlete based on outstanding athletes. If the athlete works well he/she will improve for his/her team

Always remember that a custmer must be responsible by itself and it can also be responible for other objects. There can be a lot of responsabilities for one simple class.

Using CRC Cards

First of all CRC stands for Class Responsability Collaborators, its main objective is to order the classes. Each card is for one class. A CRC card is written as it follows.

Class Name

Responsabilities Collaborators

A CRC card must be written in paper and not in a digital way because by writing it in paper it makes you more concise and you kind of remember better when you write.


Domain Modeling (Modeling the App)