Is this a good JavaScript object model? (phone book project) -


I need to make a phone book Thanks to a form, I can retrieve somebody's data. I have to use the objects for that purpose. I have created a phonebook () object with the help of a method to add a person to the phone book.
I can to divide the "person" concept decided (though it was not asked for) 2, resulting in two at a "person" object and an "address purser" object (the same person Are: "my tailors are rich!" :-))

Is this a good way to declare a person's objection?
Can we create an object without any address and then add it to the "Person2" object?

If someone can help me, then I must be very obliged if you are already thanking a lot "

  function phonebook () {this.Liste = new array ();}! phoneBook.prototype.Add = function () {Liste.push (new person (ALastName, AFirstName, AAddress));} function person (aLastName, aFirstName, aAdd) {this.LastName = aLastName; this. FirstName = AFirstName; ThiskAddress = new AddressPerson (aAdd.Street, aAdd.CP, aAdd.Town, aAdd.NumTel, aAdd.Email);} function PERSON2 (ALastName, AFirstName) {ThiskLastName = ALastName; ThiskFirstName = aFirstName; this.Address = 'unknow';} function AddressPerson (aStreet, ACP, aTown, aNumTel, aEmail) {this.Street = aStreet; this.CP = ACP; this.Town = aTown; this.Num Tel = aNumTel; this.Email = aEmail;}  

  • its class ( Phonebook ) to be capitalized, and your method / properties ( last name , add () ) be minimal,
  • Found 'A' prefix because javascript does not contain this at any time.
  • methods must take as the object parameter, for example, add (should) add (person) where man is a pre-made person object.
  • Why do you need Person2 ? It seems redundant. In the manufacturer for
  • person , you copy each field of the address . Usually it would be OK to just type this.address = address . But if you want to make sure that every person has its own example address , then clone () method to address Provide .

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -