473,383 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

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 1375

"KenA" <Ke**@discussions.microsoft.com> wrote in message
news:C3**********************************@microsof t.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**@discussions.microsoft.com> wrote in message
news:76**********************************@microsof t.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
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
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...
6
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...
12
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...
6
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...
12
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...
12
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...
22
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...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.