Mindmap
Advance programming 2
Inhalt der Mindmap
Advance programming 2
Enumerations and Bit Fields
- enum keyword used to declare an enumeration
- enum.GetValues() --> return the values of an enumeration as system array
- a distinct type consisting of a set of named constants called the enumerator list
- bit fields are enumeration that have a flags attribute that allows a bitwise combination of its member values
- bit fields can be combined using a bitwise or operation, enumerated constants cannot
- e.g. bit field with value stored in powers of 2 (1,2,4,8,16...)
- stored in binary format and combine values into single number, we can see which code is used
- i.e. 2 + 8 + 16 gives 011010, which is 000010 + 001000 + 010000
- stored in binary format and combine values into single number, we can see which code is used
- e.g. bit field with value stored in powers of 2 (1,2,4,8,16...)
- C# use codes like this when values can be true at the same time, e.g. bold, italic underline using 000001,000010 and 000100 to represent, 000011 means bold, italic but not underline
- bit fields generally used for lists of elements that might occur in combination
- so bit fields combined with a bitwise or operator to generate unnamed value
- enumeration constants are used for lists of mutually exclusive elements
- enum keyword used to declare an enumeration
Bitwise operations
- action that work at the level of single bits in a stored integer
- integer in PCs is 32-bit with each bit hold 1 or 0, starting from the rightmost
- computer system use 1s and 0s to hold sets of true/false data
- more economical in storage and processing time than hold 32 true/false values separate number
- need to be able to 1. turn a particular bit on/off. 2. check to see if a particular bit is on or off
- cannot directly do to individual bits, need to work at level of integer , this is bitwise operations
- bitwise operator
- binary operator
- combine bits in a pair of integers according to a particular set of rules
- e.g &(and), |(or), ^(Xor)
- combine bits in a pair of integers according to a particular set of rules
- unary operator
- change all the bits in a single integer according to a particular set of rules
- e.g. ~(not), <<(left shift), >>(right shift)
- change all the bits in a single integer according to a particular set of rules
- and
- check turn on or not
- or
- turn some bits on
- Xor
- not
- change bits current status
- left shift
- right shift
- binary operator
Multithreading
- the carrying out serveral different processes so they appear to be running simultaneously
- done by allocating each process a time slice in turn
- if not done right, ill effect
- value turn to utter grabage
- counters fail to increment
- application suddently freexe
- resources such as database unexpectedly close or exhausted
- types
- main thread
- worker thread
- background thread
- thread pool
- a collection of thread objects created for use by an application
- provide to each application that stays in existence, but recommended to left it to application and create own threads manually
- thread safe
- two threads use same object result in one thread affected to be meaningless or deadlock
- objects prevent destructive interference between threads sharing the objects are thread safe
- ways to nake sure only one thread at a time can access a resource
- use lock keyword
- when use by a thread, the session will remain locked until the thread leaves
- deadlock may appear if threads use more than one shared section, as two threads remain in wait states and each is waiting another thread to unlock the locked session
- when use by a thread, the session will remain locked until the thread leaves
- callback method
- method 1 passed the name of another method as a parameter and first method will call the second method at some point in its execution
- advantage is programmer can make method run code that suits the programmer but not par of the method
- method 1 passed the name of another method as a parameter and first method will call the second method at some point in its execution
- synchronous and asynchronous calls and blocking
- synchronous method call waits for the method to complete before continuing with program flow
- asynchronous method call return immediately so the program can perform other operations wihle the called method completes its work
- beginlnvoke method
- initiates an asynchronous operation
- endInvoke
- call when operation completes, always call it after an asynchronous call completes
- common ways to use
- endInvoke will block until asynchronous operation completes
- delegate begininvoke and endinvoke method are dynamically generated
- beginlnvoke method
- use lock keyword
- threads with windows form
- windows forms are not thread safe
- the carrying out serveral different processes so they appear to be running simultaneously
serialization
- process of writing objects on a persistent storage media such as a file on the disk
- Three types
- binary
- useful when storing object when both storing and using program are c#
- most compact and effecient
- allow to store an exact copy of the state of an object at a given point in time
- SOAP
- simple object access protocol
- store data in a specialized XML format
- all data can be store
- advantage: it allows the data to be passed across firewalls
- XML
- stores public data and properties in XML format
- private data is not stored
- useful for making data available in a format that can be access by other languages and platform
- n be set through firewalls
- binary
- de-serialization is we can use to restore objects from the stored form
- programmer does not have to write extra code to store an object for each class being used
- advantage is programmer only need to write a minimum of code
inheritance and polymorphism
- inheritance is where one class is defined as an extension of another class
- allowed provided the class we start with is not specified as sealed
- class that is inherited from: parent class, base class, immediate ancestor and super class
- class that built by inheriting from a parent class: child class, derived class, descendant class, sub class
- child class has all data members and methods of the parent class and can add extra data members and extra methods
- syntax for inheritance is the name of the child class followed by a colon and then the name of parent class, can have only one parent class
- the child class constructor need to receive any parameters that are needed to intialize the base class as well as the child class
- inheritance is where one class is defined as an extension of another class
Informationen
- Beschreibung
- Mindmap am Advance programming 2, erstellt von hon sam Chan am 21/06/2016.
- Erstellt von
- hon sam Chan
- Aufrufe
- 0
- Bewertung
Mehr zu Data Types, Variables and Operators