Mutable - can change, immutable - cannot change
string is immutable - you actually create a new string when you append etc
StringBuilder is physically modified when you append so its cheaper on memory
For everything, research pros and cons
Angular
+ very declarative, you know what element is bound to what as its clear in markup -everything has ng- in jQuery, it uses CSS selectors and you may not always be clear what is going where...
+ Directive can manipulate the DOM
Incremental Database Backups
Automated Testing, Automated Deploying
SOLID Principles: http://www.codeproject.com/Articles/703634/SOLID-architecture-principles-using-simple-Csharp
S rp
Single Responsibility Principle
- ensure your classes are used for single responsibilities e.g a class person can have methods to add, remove, update, delete people
- however dont sneak things in there like SendEmail and hasAccessTo
O cp
Open Closed Principle
- once you have written a class and deployed it, dont make changes to it if a new feature is required
- extend it instead
L sp
Liskov Substitution Principle
- Personalised Prospectus Application is not a student yet it is just a lead - however it is saved to the database as a person
-
I sp
Interface Segragation Principle
- similar to OCP - a good example is INEwsCollection which must implement getNewsCollection
- if you decide that a new INewsCollection consumer needs a checkNewsCollection method
- dont add the method to INewsCollection because you will have to implement in MoodleForumNewsCollection and TestNewsCollection
- extend the INewsCollection with INewsCollectionVerifed and your new class should implement the INewsCollectionVerified
D ip
Dependency Inversion Principle
- IOC sits above:Service Locato, Events, Delegates and DI (Dependency Inversion OR Injection?)
- have implemented by inverting control of which db connector to load to a DBConnector class
- an early example https://onedrive.live.com/?cid=289FADB32C0AB5D3&id=289FADB32C0AB5D3%2138959 (demonstrates my thinking)
- have implemented this using IOC for databases where you dont know which database you will need till runtime so I used polymorphism to call methods from the parent class yet I passed the child class in to call the method
- however to really implement this, you combine with SRP and dont create different instances of the interface implementor when you get into your class, inject the Interface in through the constructor, method or property
http://prodinner.aspnetawesome.com/ ASP.NET MVC Ajax
Static Classes: Really just a bucket of methods (somewhere to store things that dont belong to objects). If you declare
fields/properties in here at class level then you must make them static to be accessible in a static method.
Abstract class: Model something in a type hierarchy e.g. Vehicle is abstract and all children must inherit it and implement its methods
(almost like an interface but you can code the methods or choose not to).
Polymorphism: A collection can only hold people. You can add an employee or a student...so long as it is derived from class people.
Overloading: Multiple methods, same name, different arguments.
Overriding: Multiple methods, same name, same arguments. Use in child to override parent method. Its the same as overriding in Java
except you have to use the keyword...
Virtual keyword on method: this revolves around overriding parent methods
The virtual modifier tells the compiler that when any class derived from class A is used, an override method should be called. So the child should use the override keyword
virtual keyword on property
Race condition: Occurs in multithreading - when two threads access a shared variable at the same time. The first reads the var and the
second reads same value. They then both perform their operations on the value and they race to see which can update the value last.
Whichever thread writes last wins.
Deadlock - stalemate: two threads lock different variables then try to lock the variable that is already locked by the other thread. So they both wait till each other is free before continuing. Stalemate!
Struct: a lightweight class - use when you just want to structurally store a collection of objects. Its like new stdClass in PHP (but more organised). Its better than creating a dictionary and assigning kvps to store your lightweight collection as i have done in the past. They have limitations compared to classes and you would normally use a class. Classes are reference types while struct are value type objects. If passing a struct in place of an object, you must use the ref keyword to tell the method that the variable should be populated by reference and not value.. Only use if there is a specific need to pass an object by value and not reference.
Enum: you have a set of constants that will never change. e.g. sun - sat, jan - dec. You can declare these at namespace level so it can
be used by all classes. By default, the type of items in list are ints but these can be any primitive type except char
Delegate: used to treat a method like an object. I dont think it has any real use in the example I saw http://aspnetcentral.com/aspnet45/expert/video/0410%20Understand%20delegate%20methods.html
Fields: are basically what you thought were variables. These should be accessed via getters and setters because they abstract the field and allow you to make change...tbc
Properties: are the way you declare variables in Models with the get; set; They expose fields
Using {} - use this whenever: The using statement is only useful for objects with a lifetime that does not extend beyond the method in which the objects are constructed. Remember that the objects you instantiate must implement the System.IDisposable interface. E.G SQLConnection
FluentValidation is an alternative to data annotations. Some feel it is easier to read and maintain. http://stackoverflow.com/questions/16678625/asp-net-mvc-4-ef5-unique-property-in-model-best-practice In the example i studied, it felt like writing unnecessary code e.g. making a field unique...
Boxing: int x = 1; object y = x;
Unboxing: y = 1; x = (int)y;
The above work with casting when unboxing and generalisation (almost polymorphism) when boxing
hash region: allow you to collape blocks of code in long code and add a description so you know what each region is for
hash pragma: use to disable warnings and reenable later on
Technical Debt: When you make a change, there is often other changes to make in other parts to ensure the integrity of your application. These other changes are called debt.
IDisposable: a way to dispose of unmanaged resources - used most for db connections and talking to db via EF. Use if you are directly accessing an unmanaged resource
IEnumerable vs ICollection
Internal keyword vs private http://stackoverflow.com/questions/3813485/internal-vs-private-access-modifiers
IOC - passing the decision making away from the class to an external entity e.g. constructor should not decide which database type to instantiate. You can use DI to implement IOC. You can also use delegates, events, and service locators https://www.facebook.com/video.php?v=690253231015623
DI - Dependency Injection
Know your versions:
Visual Studio: 2013 (v12) - help about
ASP.NET: 4.5 - search targetFramework in web.config
C# : 5
MVC: 5 - search system.data.mvc in web.config
EF: 6 - search system.data.entity in web.config