LMJW Blog My notes.
Posts with the tag CS:

OOP design notes

Decomposition & Generalization Association Loosely coupled relationship between two objects. Below are the code representation. UML represents this with solid line. public class Student{ public void play(Sport sport){ ... } } public class Wine{ public void pair( food){ ... } } Aggregation More like has a relationship where a whole has parts that belong to it. The code example is below. Uml represents with empty diamond. Diamond is on the class that has other class. public class Airliner{ private ArrayList<CrewMember> crew; public Airliner(){ crew = new ArrayList<CrewMember>(); } public void add(CrewMember crewMember) { ... } } public class PetStore{ private ArrayList<Pet> pets; public PetStore(){ pets = new ArrayList<Pet>(); } public void add(Pet pet){ .

common knowledge cheat sheet

Rust String.push(char) takes char Vec has reverse method where as iterator has rev method String and &str both have chars method that convert string to Char String and &str can be split_whitespace they also can call split(pat: P) e.g split(' ') is equivalent to split by whitespace NOTE: in rust usize -1 could overflow to max, this might causing algorithm not working properly If we are dealing with linked list with Option<Box<Node>>, we can potentially using Box::clone() to overcome some limitation due to borrow checker. Box::clone should be relatively not expensive as mentioned in rust book: a box is a smart pointer to a heap allocated value of T.