WCF
- Support for strongly and loosely typed messages
- Support for bindings
- Support for the latest web services
- Integrated security model
- Stateful/stateless
- Boundaries are explicit
- Services are autonomous
- Communication via contract
- ABC
[ServiceContract] – service interface, name, namespace, protectionlevel, CallbackContract,
Session – Required, Allowed, NotAllowed
ProtectionLevel – encryption, digital signatures
[OperationContract] – method, IsOneWay, AsyncPattern, IsInitiating, IsOneWay, IsTerminating
[ServiceBehaviour] – PerCall, PerSession, Single
ConcurrencyMode – Single, Multple, Reentrant
[DataContract]
[DataMember]
[FaultContract(typeof(DataContract)]
Bindings
BasicHttpBinding – default, one direction
WSHttpBinding – More webservice features – transactions
WSDualHttpBinding – Duplex communication
NetNamedPipeBinding – Same machine
NetPeerTcpBinding – P2P network
NetTcpBinding – Duplex TCP binding
MsmqIntegrationBinding – to existing application using Msmq
NetMsmqBinding – Between .Net applications
Hosting
System.ServiceModel.dll
<services>
<service name = “Name”>
<endpoint address = http://localhost:8080/ServiceName
binding = “basicHttpBinding”
contract = “IServiceContract” />
</services>
ServiceHost host = new ServiceHost(typeof(MyService), “Uri”)
host.Open()
MEX
Meta data about service
Allows to create proxies
svcutil
Configuration
OpenTimeout
CloseTimeout
SvcConfigEditor
IsInitiating – create instance
IsTerminating – close instance
PerSession – default is 10 mins, inactivityTimeout, AutomaticSessionShutdown = false – explicit call to close the session
WPF
PresentationCore.dll, PresentationFramework.dll, System.Xaml.dll, WindowsBase.dll
DispatcherObject – Dispatcher
DependencyObject – dependency properties
UIElement – events, Focusable, IsEnabled, IsMouse….Over, Visibility, RenderTransform
FrameworkElement – storyboarding, databinding, Name property
DependencyProperty – animation, binding, DependencyPropery.Register(), inheritance, triggers, Callbacks, Coercetion
AttachedProperty – DependencyProperty.RegisterAttached
Markup Extensions – {}, extend grammar of XAML
Panel Controls
Canvas, DockPanel, Grid, StackPanel, WrapPanel, UniformGrid
Triggers
Trigger – dependency property
MultiTrigger – same as Trigger but with multiple conditions
EventTrigger – particular event has occurred, applies animation
DataTrigger – a property in datacontext has reached some value
DataTemplates – associating data context with a view
ControlTemplates – Override the whole visual representation of the control
TemplateBinding – RelativeSource{RelativeSource=TemplatedParent} or {TemplatedBinding Padding} (won’t work if you need two way}
Routed Events
Buble Events –
Tunnel Events – Preview….
Direct Events
EventManager.RegisterRoutedEvent(“Click”, RoutingEventStrategy.Bubble, typeof(RoutedEventHandler), typeof(ButtonBase));
Freezable – makes the object immutable
WPF Performance Tuning
Dispatcher.BeginInvoke / BackgroundWorker
Fix Binding Errors
Prevent Software Rendering – BitMapEffects
Virtualise Lists
Freeze Freezables
Disable Assembly Localisation
Lower Framerate of animations
Troubleshooting
Scrollbar is not visible – ??
Databinding –
Bindings
Static – compile time
Dynamic – runtime
ElementName, Path
Relative Source – Self, FindAncestor, PreviousItem,
Styles
Styles – <Style x:Key=”Name”>
<Setter Property = “Name” Value=”14”/>
</Style>
Animations
BooleanAnimationUsingKeyFrames, ColorAnimation, DecimalAnimation, Int32AnimationUsingKeyFrames
IDataError
ErrorTemplate
Data Views
ListCollectionView view = CollectionViewSource.GetDefaultView(source) as ListCollectionView;
PropertyGroupDescription
Dispatcher
Own the application thread and manages the queue of work items.
Dispatcher.CurrentDispatcher
SQL
1NF: Eliminate Repeating Groups
Make a separate table for each set of related attributes, and give each table a primary key. Each field contains at most one value from its attribute domain.
2NF: Eliminate Redundant Data
If an attribute depends on only part of a multi-valued key, remove it to a separate table.
3NF: Eliminate Columns Not Dependent On Key
If attributes do not contribute to a description of the key, remove them to a separate table. All attributes must be directly dependent on the primary key
Index
An index is a physical structure containing pointers to the data. Indices are created in an existing table to locate rows more quickly and efficiently
Clustered indexes define the physical sorting of a database table’s rows in the storage media. For this reason, each database table may have only one clustered index.
Non-clustered indexes are created outside of the database table and contain a sorted list of references to the table itself.
Primary Key – creates a clustered index, cannot be null
Unique Key – non-nonclustered index by default, can be null
Delete – can have where clause, foreign keys are checked, activates triggers
Truncate – will remove data and reset auto increment. Truncate is not logger, cannot be rolled back
Function – can be used in WHERE/HAVING/SELECT
UPDATE_STATISTICS – after large dataset has been processed
Joins – INNER JOIN, OUTER JOIN, CROSS JOIN, LEFT JOIN, RIGHT JOIN
Log Shipping – the process of automating back up of database and transaction log files
Replication – Snapshot, Transaction – updates, Merge – updates when connected
Permissions
GRANT/DENY/REVOKE
Execution Plan
An execution plan is basically a road map that graphically or textually shows the data retrieval methods chosen by the SQL Server query optimizer for a stored procedure or ad-hoc query
Wildcats – % any group of characters, _ – single character, [ab] – a or b
Locks – Shared locks – SELECT, Update locks – to update a page, Exclusive Locks – UPDATE/DELETE/INSERT
Triggers – UPDATE/INSERT/DELETE
Instead of Triggers – ignored instead the code is fired
Transaction Isolation Levels
READ UNCOMMITED – can read data that has been modified but not yet committed. Dirty reads. Phantom reads
READ COMMITED – cannot read that has been modified but not yet committed. No dirty read. Default. Phantom reads
REPEATABLE READS – no other transaction can read data that has been modified by the current transaction until it’s committed. Phantom reads
SNAPSHOT – does not require read locks. Takes snapshot. Data modifications made by other transactions are not visible by this transaction
SERIALIZABLE – cannot read until committed, no other transaction can modify data
.NET Performance
Reference Type Internals – Object Header Word (-4), Method Table Pointer (+0), Storage for_id (+4), Storage for_name (+8)
- Object Header Word – Sync Block Index, HashCode storage,
- Aligned to 4 or 8 bytes
Value Types – compact, implement IEquitable<T>
LOH – 85KB, not compacted
Finalisation – added to finalization queue, removes the reference to that object, moves to f-reachable queue. Finalizer is run on finalization thread
GC Process
Mark Phase – find a list of all live objects
Relocating – changes references to the objects that will be compated
Compation – Moved objects towards the older end of the segment
Workstation GC is only used on single CPU pcs
Concurrent GC – can allocate on Gen0 and Gen1 if have free space, otherwise have to wait for collection.
Background GC – objects in Gen0 and Gen1 are collected as normal even though the collection in Gen2 is taking place.
System.Runtime.GCSettings
- Batch – for applications that have no UI or server side applications
- Interactive – for UI applications
- LowLatency – minimizes latency short term
- SustainedLowLatency
Design
Creational
Abstract Factory groups object factories that have a common theme.
Builder constructs complex objects by separating construction and representation.
Factory Method creates objects without specifying the exact class to create.
Prototype creates objects by cloning an existing object.
Singleton restricts object creation for a class to only one instance.
Structural
Adapter allows classes with incompatible interfaces to work together by wrapping its own interface around that of an already existing class.
Bridge decouples an abstraction from its implementation so that the two can vary independently.
Composite composes zero-or-more similar objects so that they can be manipulated as one object.
Decorator dynamically adds/overrides behaviour in an existing method of an object.
Facade provides a simplified interface to a large body of code.
Flyweight reduces the cost of creating and manipulating a large number of similar objects.
Proxy provides a placeholder for another object to control access, reduce cost, and reduce complexity.
Behavioral
Chain of responsibility delegates commands to a chain of processing objects.
Command creates objects which encapsulate actions and parameters.
Interpreter implements a specialized language.
Iterator accesses the elements of an object sequentially without exposing its underlying representation.
Mediator allows loose coupling between classes by being the only class that has detailed knowledge of their methods.
Memento provides the ability to restore an object to its previous state (undo).
Observer is a publish/subscribe pattern which allows a number of observer objects to see an event.
State allows an object to alter its behavior when its internal state changes.
Strategy allows one of a family of algorithms to be selected on-the-fly at runtime.
Template method defines the skeleton of an algorithm as an abstract class, allowing its subclasses to provide concrete behavior.
Visitor separates an algorithm from an object structure by moving the hierarchy of methods into one object.
SOLID Principles
Single Responsibility
Open Closed principle
Liskov substitution principle
Interface segregation principle
Dependency Inversion Principle
FIX Protocol
1 – Account Id
8 – BeginString
9 – BodyLength
35 – MessageType
34 – MsgSeqNo
49 – SenderCompId
56 – TargetCompId