How is abstraction realised in a system? - encapsulation

Some say abstraction is achieved through abstract class, while others say it is achieved through encapsulation. I am confused, would someone advise?

'Abstraction' is a very vague word covering many.many ideas in programming (and system design)
abstract classes are a very concrete mechanism in some languages.
encapsulation is a common object oriented design pattern used in some languages
Are these 2 models used for abstraction, yes. Are they the only ones, no.

Related

Is there a name for the pattern of injecting implementations into a portable class library?

Apologies for the not entirely code related question.
I am in the process of building a WPF application with a View Model Locator pattern. In that I have interfaces to represent functionality not present in portable class libraries.
I then assign those properties concrete values in my application so that they are available for injection to my view models.
My question is, do we have a name for this pattern? It seems a standard enough way to do this but I am never sure what to call it and end up having to explain it every time.
A term Microsoft uses to describe the way one can inject in a PCL concrete implementations of code that cannot be written to directly target a PCL is platform abstraction.
There are several techniques to achieve this. Here are some useful links:
http://blogs.msdn.com/b/dsplaisted/archive/2012/08/27/how-to-make-portable-class-libraries-work-for-you.aspx
http://blog.stephencleary.com/2012/11/portable-class-library-enlightenment.html
http://log.paulbetts.org/the-bait-and-switch-pcl-trick/

Structural Diagrams for C

I am trying to read and understand the source of an existing C project. I keep feeling like it would be great to draw a UML Class Diagram for it to help me understand the high level relationships better, but of course - there are no classes to model.
Is there a formal diagram system that is used to model module relationships in a non-OO language? One that would be on a similar level of abstraction to a UML Class Diagram.
One alternative is to use Doxygen to map your function tree.
The OO paradigm is not a property of programming language and it's very possible to make OO implementation in C (just hard and not very intuitive). The OO design (in UML or any other modeling language) is not bound to a specific language.
Now let's get back to your question. There are many tools available for non-OO design. You can find a nice summary here and choose what fits you best.
Try FMC ( http://www.fmc-modeling.org/home) and "Apache Modelling Project" (Apache HTTP Sever modeled using FMC: http://www.fmc-modeling.org/projects/apache) as a starting point and guideline.

Programming Paradigm Beginner

easy theory question.
I have a couple years experience with PHP and Javascript, trying to branch out into other languages and to connect my experience with some theory.
Have been reading about programing paradigms like imperative, functional, object-oriented, etc. Is there any reason, within a particular program, to commit to one paradigm or another? I can think of reasons to mix, say, object oriented statements with functional statements, but then yo read about like, whole languages that 'belong' to a paradigm (like Lisp and functional programming, for example)
Is there any reason or advantage to commit to a particular paradigm, or is it okay to just roll with what works?
Most software today is built using Object Oriented Programming, because this paradigm makes it easy to organize large amounts of code. With that said, the more paradigms you know, the better.
One particular paradigm of interest is functional. While pure functional programming isn't used very often in industry programming, a lot of the ideas are currently spilling over to Object Oriented languages like Java and C# (like the concept of first class functions, and avoiding mutation). Once you learn new paradigms, it'll change (and often improve) the way you program in other, more common or popular programming paradigms.

Aspect Oriented C (not C++) in Production Code

This is a question further derived from a previous one: https://stackoverflow.com/questions/1834485/aspect-oriented-programming-aop-in-c-not-c-anyone-doing-it
The answers to that question point us to some research practices at queens university here:
http://sailhome.cs.queensu.ca/~bram/aspicere/index.html.
Beyond that research effort, does anyone know of real world usage of Aspect Oriented C in production code? If no, where do you think the difficulty is? If yes, what's the hurdle that makes it unpopular yet?
I think the benefit of AOP is obvious. But after AOP-Java becoming popular for a decade, AOP-C is still almost non-existent, there must be some reason. What's your insight on this?
After some thinking I believe the answer is that C lacks the structural constructs where you can hook up your aspect cross-cuts.
To get around of this problem, a project would have to impose strict structural conventions that is not easy to have programmers to agree on. If you do have programmers to agree on to such a convention, the chance is that the project would have chosen a better language.
I think the main reason is that traditional method to implement the AOP in C/C++ needs a complex framework to make things work.
Beside, the C++ is strict type language, which makes the implementation even harder than C.
But, It is the old time. new C++ 11~17 provides some really powerful features for you to do all the tricks.
You could check this one: https://github.com/whitebob/qaop
A very light-weight, header-only AOP framework, and it is easy to use.
I am the author of this on-going project, so if you have some suggestions or complains, just contact me :p

Regarding multiple inheritance

Can anyone explain me
why c# not supporting multiple inheritance since c++ supporting multiple inheritance ? how it is possible ? How c++ supports ?
First, a small correction: C# does support multiple interface inheritance. It doesn't support multiple implementation inheritance.
The two big reasons MI isn't supported are:
Chances are good that you can do what you want with multiple interface inheritance anyway.
It adds a lot of complexity to the compiler implementation.
IMO, in many cases, the availability of multiple inheritance in a language causes that feature to be frequently abused. Single inheritance already gets wedged into a lot of class hierarchies unnecessarily when something like composition would do just as well.
From an MSDN blog on C# frequently asked questions you can find this answer. There is also this highly rated Stack Overflow question.

Resources