Why is there so much talk about security in targeted programming?

Asked

Viewed 164 times

0

I program in C and now I decided to explore the world of POO through the C#language. I see that many people talk about security and this is precisely my doubt, when programming I see that the development environment itself limits me access to private classes as well as their attributes and their methods. When I define this class as public everything that belongs to it is accessible within other classes.

1° Define as private a class protects the programmer’s code or the user’s application?

2° If I access attributes and methods of an A class in a B class I will be compromising the security of the application?

If someone can also give me some tips related to code organization I will be grateful, because I am used to C so I have always modularized my code separated by 2 headers (functions and libraries) and 1 .c where I call all the functions. Since C# has the advents of classes and security:

3° What would be the best way to organize everything in scripts safely?

  • 1

    There are many books that and people who speak several things without any foundation.

  • Did the answer solve your question? Do you think you can accept it? See [tour] if you don’t know how you do it. This would help a lot to indicate that the solution was useful to you. You can also vote on any question or answer you find useful on the entire site.

1 answer

3

Security is a property that has nothing to do with object-oriented programming. Perhaps the term was another.

Defining something as private does not protect anything. The compiler does not let you use normal code that calls that member. Nothing prevents the member from being accessed in unusual ways, such as reflection. It does not even protect an instance from accessing private members from another instance of the same class.

This note on the limb is just an indicator of what you shouldn’t do. This has to do with encapsulation, with concealment of information unnecessary to the code. But do not understand concealment with protection. It’s just that it’s in a wrapper, if you want to open it’s all there to see.

Accessing members of a class does not compromise any security. If this were to occur, you wouldn’t even be able to do anything.

It is possible to use private classes, but they are almost never useful, a private class can only be accessed within another class where it has been declared.

C# may be used like this but it is not a language of script.

It becomes complicated to answer the other questions, I suggest asking more specific questions and more details.

I also suggest looking for a structured way to learn these concepts, maybe a good book.

  • Bigdown, thank you for your reply. What book would you recommend based on your experience so that I can understand these concepts that so far are quite unconnected to me?

  • I don’t like to recommend books, but there’s a list in http://answall.com/tags/c%23/info.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.