«

»

2月 04

A48: TT1 Notes for the noobs

OOP:

  • Yes, we are playing with Class.
  • Are you sure when you should define variables?(before/after _init_?) This is called Instance variable versus Class variable.
  • Inheritance: Father and child. Children can override father’s method.
  • So WHY? We want 1) no need to deal with tons of functions 2) make a “wrapper” method for lots of works 3) similar Classes, same method
  • Python is a week type language: the type of variable can be changed on the fly.

Encapsulation:

  • I mean…why copy your code for several times for doing the same thing?

Modular Programming:

  • Because no one would remember what the heck he had done 2 weeks ago
  • Also, people are forming groups to getting jobs done: think about popular open-source softwares.
  • Enable you to use the same stuff multiple times later

ADT:

  • We want to organize the inputed data.
  • Putting data into your machine feels good: taking them out can be pain in the a*s.
  • If you happen to need to sort your stuff or find something…
  • We focus on its behavior.
  • Don’t focus on its name: I can name my cat “puppy” , but it won’t bark.
  • This part of A48 is actually called “Data Structure”.

Bucket:

  • No this is NOT a common ADT.

Queue:

  • FIFO.
  • You can implement a Queue with a Doubly Linked List(DLL).
  • Wanna play with enqueue/dequeue/peak/isempty/len/etc.

Stack:

  • FILO.

Exceptions:

  • Yes you can handle exceptions in the code;
  • But maybe you just want to exit the function.
  • Exceptions are not equal to ERRORs: it only matters how you handle it.
  • Make sure you are catching the RIGHT one and ENOUGH ones. Names are important.
  • A pure except would catch everything. But is that what you want? You really want to include KeyboardInterrupt?

UML:

  • Objects: Nouns.
  • Methods: Verbs.
  • Attributes: Variables.
  • Said Nick.
  • If you do not understand it…how did you wrote your DocString?
  • You want to include the above 3 stuffs, linked.

LL:

  • Lovelive
  • Single/Double
  • Can become a Queue, Stack…or a branch of a Tree!

发表评论

电子邮件地址不会被公开。 必填项已用*标注

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">