A glossary of terms used in software engineering
-
Declare
Introduce a new variable with a type and a name:
int x;
Note: in C# with will cause a compile time error if
x
is used without being assigned. Or it could be that it can be declared but will only error if it is used without being assigned. -
Assign (or Set?)
Provide a variable with a value.
int x; // Declare x x = 5; // Assign 5 to x
-
Instantiate
Create a new instance of a class
var myObject = new MyObject();
is this also instantiation?:
MyObject myObject; // Declare myObject myObject = new MyObject(); // Instantiate myObject with a new MyObject instance
-
Initialise
Declare a variable and assign a value to it
int x = 5
Minimal Working Example: https://en.wikipedia.org/wiki/Minimal_Working_Example
Inheritance Hierachy - The total chain of inheritance between the most base class and the most derived class. In C# the root (or base) of the hierarchy is the Object class.
- https://docs.microsoft.com/en-us/dotnet/csharp/tutorials/inheritance
- https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/object-oriented/inheritance
Subclass (the child class or derived class)
Superclass (the parent class or direct base class)
- Extends, Derives, Inherits - Terms for how a child class relates to a parent class (concrete or abstract), or a child interface relates to a parent interface.
- Implements - Term for how a concrete or abstract class relates to an interface. These classes provide an implementation for members defined in the interface.
- Overrides - Provides a new implementation for an existing method implementation (using
new
) or virtual method.
inheritance is transitive
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/abstract-and-sealed-classes-and-class-members https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/interface https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/virtual
Been wrapping my head around covariance and contravariance. These are simplest version I can come up with:
interface ICovariance<out T>
{
T CanOut();
void CantIn(T value);
}
This will have a compile time error on the T
parameter in CantIn
as the out
on the generic type specifies that this type can only be returned, not passed in as a parameter; an example would be IEnumerable
.
interface IContravariance<in T>
{
T CantOut();
void CanIn(T value);
}
This will have a compile time error on the T
return from CantOut
as the in
on the generic type specified that this type can only be used as a method parameter; an example would be IComparer
.
Incidentally, a property like public T MyProperty { get; set; }
could not be used in either interfaces, as it both gets and sets T.
Building on this, with covariance, a derived class can be used instead of the base class (a child can be used where a parent is specified; think liskov substitution in SOLID). Where as, with contravariance, a base class can be used instead of the derived class; so in the case of a Comparer, the base class's comparer is used to compare instances of the derived class. This is possible because the derived class has all the members of the base class to allow the base class comparer to work.
Prefer composition over inheritance.
- https://scottlilly.com/c-design-patterns-composition-over-inheritance/
- https://medium.com/humans-create-software/composition-over-inheritance-cb6f88070205
- https://stackoverflow.com/questions/49002/prefer-composition-over-inheritance
- https://www.thoughtworks.com/insights/blog/composition-vs-inheritance-how-choose
https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/methods https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
Signature
- access modifier
- return type
- name
- parameters (arguments) https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/named-and-optional-arguments
Body
- The term for a line of code, is it Operation, Statement, Expression?
- Side Effect
- Parsing
- Santising
- Interning
- Class Members - https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/members
- Fields
- Properties
- Event handlers
- Methods
- anything else?
- Encapsulation
- Discoverability - How easy is a term, piece of code, or class to learn about or discover. The problem is if something isn't easy to discover or required to use, then other solutions will be created, causing duplication and further reducing discoverability of the preferred approach.
- Debugging
- Replicate or reproduce issue
- Intermittant issue
- Connascence - https://connascence.io/
- SeedWork
- https://martinfowler.com/bliki/Seedwork.html
- https://maetl.net/frameworks-and-seedworks
- https://docs.microsoft.com/en-us/dotnet/standard/microservices-architecture/microservice-ddd-cqrs-patterns/seedwork-domain-model-base-classes-interfaces
- https://www.artima.com/forums/flat.jsp?forum=106&thread=8826&start=0&msRange=16
- Conditional or Conditional statement: A conditional statement is when we want to execute a certain action depending upon an available condition.
- Convention (such as Layout Convention or Naming Convention) - The approach recommended for this language or environment.
- Compiled vs interpreted code
- Scope - https://en.wikipedia.org/wiki/Scope_(computer_science)
- Invariants - Something that does not change or vary. In software it is the logical rules that define how the system is expected to (and should) operate. That is, the code might change but the invariants or rules remain the same. The idea of invariants can be extended to the system. These are the behaviours we expect the system to exhibit. So rather than it being a lower lying technical expectation, of how, say a sorting algorithm is expected to operate, these are how a user expects the system operate for the given domain. - https://en.wikipedia.org/wiki/Invariant_(mathematics)#Invariants_in_computer_science
Invariants also apply to values (like an entity's id), if the system has the rule an entity's id does not change then this an invariant - a rule that defines the system. Having certain values like
id
be immutable can be a condition or invariant of the system (eg: entities must have a stable and enduring identity). - Immutable
Verbatim string String Literal Interpolated String
- Prettify - Split the code across multiple lines to make it more human readable.
- Minify
These provide a way of measuring the quality of the code in terms of readability and maintainability.
- Cyclomatic Complexity
- Connascence - https://connascence.io/
- https://docs.microsoft.com/en-us/visualstudio/code-quality/code-metrics-values?view=vs-2017