![]() ![]() Indirect: Bob has agreed that his company will deliver a lawnmower to my house after processing my credit card payment online.Direct: I will hand Bob $70 cash for his old lawnmower.Without concrete elements, software is nothing more than a beautiful shell of uselessness. Things which are more concrete are what enables and empowers the abstractions – they make everything work. Things which are more abstract are more generally usable, and are easier to reason about. High abstraction in software operates in business concepts such as calendars, schedules, orders, customers, slides, pictures, etc. Low abstraction in software operates with full knowledge of details such as memory addresses, pointers, threads, registers, encodings, http status codes, etc. High abstraction occurs when all details are left out, and only general concepts are communicated. Low abstraction (concrete) occurs when details are very specific and explicit. The second dimension is about level of abstraction. Flexible software is harder to create, more complex, harder to understand, and harder to maintain. When there are expected dimensions of software change, it can be worth paying the cost to create software with higher flexibility. Things that are directly connected are simple, faster to build, and easier to understand. Neither high-coupling nor low-coupling is inherently good or bad. Low coupling exists where things are indirectly connected. High coupling occurs when things are directly connected. The first dimension is the degree of coupling. Both of them are important for creating simple, flexible, usable software. There are two different dimensions in play here. The Two Dimensions of Software Variability Let’s look at how abstraction and indirection relate, and how to correctly connect components. The confusion often leads to design changes that leave the code worse than before it was touched. This is partially because of the keywords abstract and interface in statically-typed languages such as Java and C#. Since this operator is used in an unsafe context, the keyword unsafe should be used before it along with the /unsafe option during compilation.The concept of abstraction in software development is frequently misunderstood and confused with indirection. When the indirection operator is applied to a null pointer, it results in an implementation-defined behavior. The indirection operator is distributive in C#, unlike C and C++. When declaring multiple pointers in a single statement, the indirection operator should be written only once with the underlying type and not repeated for each pointer name. However, after casting a void pointer to the right pointer type, the indirection operator can be used. It should not be applied to a void pointer or to an expression that is not of a pointer type, to avoid compiler errors. The indirection operator should be used to dereference a valid pointer with an address aligned to the type it points to, so as to avoid undefined behavior at runtime. ![]() The dereference operator is used in line 3 to assign the value at the address pointed to by pInt to the integer variable b. In line 2, the address of a is stored in the integer pointer pInt (line 2). ![]() In the first line above, a and b are integer variables and a is assigned a value of 1. The following C# statements illustrate the usage of the indirection operator: In the unsafe region, the indirection operator is allowed to read and write to a pointer. Hence, the indirection operator and the address-of operator are inverses of each other.Ĭ# allows using pointers only in an unsafe region, which implies that the safety of the code within that region is not verified by the common language runtime (CLR). The (*) symbol is used in declaring pointer types and in performing pointer indirection, while the ‘address-of’ operator () returns the address of a variable. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |