I would say I am a pretty basic/intermediate programmer (compared to all you lot) and I just have a query about using OO in general. While I was at Uni I got the impression from classes that the idea of OO was you have a class file, with a decent name that basically takes a variable or an object, does it's magic and returns the value. The main benefit being if someone says "how do I code a method that writes a text file?" somebody can say "just create an instance of the class and its done". This got me thinking with a simple project I am doing (it works but I want to check if I am doing it right).
I am creating a web application in C# using VS 2005. I have a number of .pdf documents that have got to be renamed and moved into relevant folders so I thought to make life easier I would allow users to enter the details in text boxes to save then opening and changing folders. Here is a method from my class:
The code below is in my .aspx.cs file and accesses the method
Basically what I am asking is shouldn't the variables be declared and assigned on
the .aspx.cs page? That way if I ever needed to create a directory I would not need to change any code in the class, just the code in my new application/page?
I am creating a web application in C# using VS 2005. I have a number of .pdf documents that have got to be renamed and moved into relevant folders so I thought to make life easier I would allow users to enter the details in text boxes to save then opening and changing folders. Here is a method from my class:
Code:
//Date: 03/11/2006
//Summary: This method takes a session value and creates a directory ready for .pdf files
//to be inserted.
public void MakeDirectory(string FolderName)
{
Directory.CreateDirectory("T:\\EUStore\\" +FolderName.Trim());
}
The code below is in my .aspx.cs file and accesses the method
Code:
protected void CreateFolder()
{
string SessionFileNumber = "" + Session["SessionFileNumber"];
EUStore TheEUStore = new EUStore();
TheEUStore.MakeDirectory(SessionFileNumber);
}
Basically what I am asking is shouldn't the variables be declared and assigned on
the .aspx.cs page? That way if I ever needed to create a directory I would not need to change any code in the class, just the code in my new application/page?