473,804 Members | 2,109 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Protecting methods

Suppose that in the class named the ProductDB.cs I want to protect the
method logic from being accessed from other classes, but I still want to let
other classes to call the method. The protected method is:

private static ArrayList ReadProducts()
{
...all the logic to goes here
}

In order to let other classes to access this method I then create a public
method that just calls the private method, like:

public static ArrayList GetProducts()
{
return ReadProducts();
}
private static ArrayList ReadProducts()
{
...all the logic to goes here
}

Is it a good design for this idea?

Regards,
KenA
Nov 17 '05 #1
4 1396

"KenA" <Ke**@discussio ns.microsoft.co m> wrote in message
news:C3******** *************** ***********@mic rosoft.com...
Suppose that in the class named the ProductDB.cs I want to protect the
method logic from being accessed from other classes, but I still want to
let
other classes to call the method. The protected method is:

private static ArrayList ReadProducts()
{
...all the logic to goes here
}

In order to let other classes to access this method I then create a public
method that just calls the private method, like:

public static ArrayList GetProducts()
{
return ReadProducts();
}
private static ArrayList ReadProducts()
{
...all the logic to goes here
}

Is it a good design for this idea?


It doesn't appear to get you anything at all, so why not just make the other
one public? How exactly is that protecting the method logic? Are you talking
with an obfusticater?
Nov 17 '05 #2
"Daniel O'Connell [C# MVP]" wrote:

It doesn't appear to get you anything at all, so why not just make the other
one public? How exactly is that protecting the method logic? Are you talking
with an obfusticater?


No, not obfuscator. I´m just not sure if doing the private method
ReadProducts() as a public one is the best way to go. Is there a way to let
ReadProducts() method to be available to other classes and in the same time
make it a private method?
Nov 17 '05 #3

"KenA" <Ke**@discussio ns.microsoft.co m> wrote in message
news:76******** *************** ***********@mic rosoft.com...
"Daniel O'Connell [C# MVP]" wrote:

It doesn't appear to get you anything at all, so why not just make the
other
one public? How exactly is that protecting the method logic? Are you
talking
with an obfusticater?
No, not obfuscator. I´m just not sure if doing the private method
ReadProducts() as a public one is the best way to go. Is there a way to
let
ReadProducts() method to be available to other classes and in the same
time
make it a private method?


Well, why does it need to be private if an external consumer needs access to
it? I'd say just let it be public unless you have a reason not to
(obfustication, public method needs extra processing).

Nov 17 '05 #4
That´s probably nonsense ... as you said if an external consumer needs access
to it, then it should be public. Thanks :-)
"Daniel O'Connell [C# MVP]" wrote:

Well, why does it need to be private if an external consumer needs access to
it? I'd say just let it be public unless you have a reason not to
(obfustication, public method needs extra processing).

Nov 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

24
5059
by: Yang Li Ke | last post by:
Hi guys! Anyone know a way so that users purchasing my scripts would not be able to share them with other people ? Yang
18
5733
by: Alan Sheehan | last post by:
Hi pythonistas, I am looking for methods of deploying applications with end users so that the python code is tamper proof. What are my options ? I understand I can supply .pyc or .pyo files but they can easily be reverse engineered I am told. Is it possible to load the scripts from zip files where the zip files are password protected ?
6
1990
by: nell | last post by:
Hi all, I've developed a testing application in python, and should supply it in a way that no one (lets say they are regular users) will understand it and edit it. The application source is all python but we expose a UI written in C# that go over all our code and expose to user functions (Indicated with a special prefix). So the problem on one hand is protecting the source and make it less accessible ond on the other hand to make it...
12
2207
by: Roland Hall | last post by:
I read Aaron's article: http://www.aspfaq.com/show.asp?id=2276 re: protecting images from linked to by other sites. There is a link at the bottom of that page that references an interesting article about ways of protecting your images from being downloaded. It was my understanding that if the client sees it, then it's in the client cache. Am I wrong in this belief or not? I took the information in the article and created the .asp that...
6
1780
by: Nate A | last post by:
I am at the beginning stages of writing a massive database-connected business management application using the .NET framework and am becoming worried about the security of the application upon completion. I have recently become aware of the ease at which a .NET assembly can be disassembled into its easily readable, underlying CLI code. I can see that it would not be difficult for a malicious user to disassemble, modify, and then...
12
1958
by: Dr. Edmund M. Hayes | last post by:
I wrote a access program that works well enough that a handful of people would like to buy it from me. My problem is that if I sell it to someone there is no mechanism that I know of to protect them from giving it to anyone they feel like. The program produces reports that are specific to a particular organization but that does stop anyone from just modifying that report to make it specific to another organization, who they might have...
12
1596
by: David | last post by:
Hi, I want to be able to make a class only visible within the namespace, i.e. only other classes within the namespace will have access to it. I have tried putting a protected keyword against it. That doesn't work. I have tried nesting it inside the class where I want to use it, this sort of compiles, except some of my methods that rely on the class have "Inconsistent accessibility:"
22
2635
by: flit | last post by:
Hello All, I have a hard question, every time I look for this answer its get out from the technical domain and goes on in the moral/social domain. First, I live in third world with bad gov., bad education, bad police and a lot of taxes and bills to pay, and yes I live in a democratic "state" (corrupt, but democratic). So please, don't try to convince me about the social / economical / open source / give to all / be open / all people are...
0
1149
by: xamman | last post by:
hi there! according to msdn (link at bottom) i should be able to protect a whole class declaratively as above. However i keep getting 'request for principal permissions failed' exceptions. in the msdn article a reference is made to include AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal) in your code to set the appdomain principal.I can understand how to use setprincipalpolicy to protect a method declaratively...
0
9716
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10604
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10354
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10359
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9177
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6870
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5536
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3837
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.