|
Hi,
Here i required some help in architecuring my Project.Here is whole senerio.
My project is already made in C# which is having around 60 .cs files.In my project,there is one main form and from that form i am calling and using all others .cs files of whole project.Currently there is somany coding available into main form.
Here another thing is that we are not using any database like sql or oracle but storing data into xml files as this is project requirement.
Now main thing is that as we had decided to build proper architecture of this project by which we can make it like library.Now from where to start i am confused so can anybody help me out here.
thanks.,
regards.,
|
|
|
|
|
Well, it sounds like all your code apart from the main form is just providing business logic for that form, and therefore could be moved into a library and imported into the project. Why do you want to build a library ? What benefit are you looking for ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
By making the library our client can use that library and use that library into their other projects.That's main advantage of making that library.
so that's why we want to make proper architecture of our code.so now can you suggest me some good idea about how to architecte this.?
regards.,
|
|
|
|
|
Hi,
By making the library our client can use that library and use that library into their other projects.That's main advantage of making that library.
so that's why we want to make proper architecture of our code.so now can you suggest me some good idea about how to architecte this.?
|
|
|
|
|
I don't see what's so hard. First of all, I don't know enough about your specific system to offer specific advice, secondly, all you need to do is pull all the non-UI code into a code library DLL, and import it into your project. I can't percieve of how I could give specific advice to help you to do that, unless you have no idea how to create a project that compiles to a dll.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
I tell you some more on my exact requirement here.You can assume my project just like paint in which one main form is there and user can create project folder,load image and create different different shapes from the menu items of the main form so for us the architecture & coding of this form is important.
Here main thing is that every menu items say when you click menuitems like file--> images goes to one methods and do required functionality same thing is for all menu items but as all those methods are in form itself and i don't want to depend on this form becoz i want to make layerwise architecture.
As all methods are very unique and calls only 1-2 times from mainform so if i put those forms methods into one class and make dll then is that good way to do that?
if i am doing that i have to pass controls as parameters of those methods.
can you tell me that if i put those forms methods into one class and make dll then is that good way?
if you have some more good idea here to build architecture than it's good.
regards
|
|
|
|
|
montu3377 wrote:
As all methods are very unique and calls only 1-2 times from mainform so if i put those forms methods into one class and make dll then is that good way to do that?
They don't need to go into the one class, no.
montu3377 wrote:
if i am doing that i have to pass controls as parameters of those methods.
Don't pass controls to middle tier methods, that ties them to the presentation tier. Perhaps create an enum, and a method that generates an enum value from a control value, as a helper function in the presentation tier.
montu3377 wrote:
can you tell me that if i put those forms methods into one class and make dll then is that good way?
If your product is a paint program, then creating a layer that is distinct from the presentation layer will be harder to do right, because it's all about what you display. Certainly don't put everything in one class, that will be more of a hinderance than having no middle tier is. To be honest, I've written some big paint programs, and I've focused on a good class structure, and not on loading anything via dlls. The only way that can be good is if you can write the main program to be generic, and to dynamically load tools from a dll, then you can distribute a new dll to add new tools, or fix tool bugs.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
If you had put some sort of article of that paint programme then can you pls. send me link or url of that?or can you pls. give me 1 sample code how to create that types of architecture?
Thanks.,
|
|
|
|
|
It was a commercial product. Basically, I wrote a base class like this:
toolbase
{
void OnLButtonDown
void OnKeyPress
void OnPaint
//etc, etc.
}
Then each tool would inherit from toolbase, and do whatever it should in those methods. Finally, my main window kept an instance of toolbase, which was then changed as the tool was changed, and it caught all these events, and called the methods on the tool when they occured.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi,
i had implemented as you said above,main problem is that i can't just declare method otherwise i have to define that method and class as abstract and if i am defining that class as abstract then in the form i can't make the new instance of that class becoz we can't create instance of abstract class.
second way,simply i can directly create instance of second class that inherited base class in that case why had created base class that is also question.Here i am sending u one simple code what i am doing.
//this is base class
public abstract class ToolBase
{
public abstract void mnuNewProj_Click(object sender, System.EventArgs e);
}
//second class that inherits toolbase class
public class InputComponent:ToolBase
{
public override void mnuNewProj_Click(object sender, EventArgs e)
{
//done implementation
}
}
but from main form i can't able to create new instance of Toolbase class becoz it's abstract.
Now can you tell me some more over here.I really like this design but need some more clearification.
thanks you a lot in advance.
|
|
|
|
|
montu3377 wrote:
we can't create instance of abstract class.
My 'toolbase' class is abstract, and I create an instance of it in my application, no problems. I never create an instance of toolbase though, that's not what it is for, the base class is useless by itself anyhow, that's not what it is for.
montu3377 wrote:
second way,simply i can directly create instance of second class that inherited base class in that case why had created base class that is also question.Here i am sending u one simple code what i am doing.
You create a base class because your app only needs to use one tool at a time, so you carry an instance of the base class, but you instantiate it as instances of the derived classes. i.e. if you click the FreeHandDraw button then my instance of toolbase gets instantiated as an instance of toolFreeHandDraw. The point is that catching UI events is common to all tools, so it's defined in a base class, so I don't need to switch between drawing modes with every UI event to figure out which control to send the event to.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
HI,
I got your point what you means to say here i had implemented two classes and call it from main form as below.Just let me know is it ok or not.If any improvement is required then pls. tell me becoz after that i will do implement into whole project.
toolbase class
//base class
public abstract class ToolBase
{
public abstract void mnuNewProj_Click(object sender, System.EventArgs e);
}
//child class implemented that method
public class InputComponent:ToolBase
{
public override void mnuNewProj_Click(object sender, EventArgs e)
{
//doing implementation code here
}
}
//From the Main Form (presentation layer) calling the child class and that method into click event
//Main form
public class main
{
private void mnuNewApp_Click(object sender, EventArgs e)
{
InputComponent input = new InputComponent();
input.mnuNewProj_Click(sender, e);
}
}
Pls. check the above code and if any improvement need than tell me.
it's working fine but i am afraid that in later on stage i have to pass controls into both classes as return values so it gives effect on main form.
pls. let me know urs comments on above code.
Thanks a lot for your nice co-operation.
Really appriciated your efforts.
|
|
|
|
|
montu3377 wrote:
it's working fine but i am afraid that in later on stage i have to pass controls into both classes as return values so it gives effect on main form.
Creating a new image is not a tool, the class that encapsulates an image window should be carrying the tool here, and the tools should be draw/fill/shape/text/etc.
montu3377 wrote:
Thanks a lot for your nice co-operation.
Really appriciated your efforts.
That's cool - you happened to ask in an area that I have a lot of experience, so glad to help
Overall, the class structure is fine, but I'd expect the tools to work like this: ( this is pseudocode, it won't compile )
class MyMainWindow
{
private ToolBase tool = new ToolNone; // Create an empty tool so the variable never has to be null
OnMenuClick()
{
switch(menuItemClicked)
{
case text:
tool.Dispose(); // Your tools will have resources you should delete in an IDisposable implimentation
tool = new ToolText(this); // The constructors will need a copy of the window if the tools are to call Invalidate() to make the window redraw when needed
break;
case freehand:
tool.Dispose();
too = new ToolFree(this);
break;
// etc
}
}
OnMouseClick(args)
{
tool.OnMouseClick(args);
}
// etc
}
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Hi all,
I wonder if anyone can help, I'm at a complete loss about the behaviour I'm seeing!
I've created an Outlook COM-addin project in VS2003 (this is via the Wizard). The trouble is is that I'm trying to get the installation path because there are files that are installed that I want to load/access. (I don't really fancy using resource file(s) at this time)
To get the install path I'm using:
this.getType ().Assembly.Location
now the trouble is that on my local machine this is returning the path of where the .dll file has been created by VS2003 (in the bin\Debug directory) NOT the install path (which is different, and on a different partition to the build path).
Anyone any idea why?
What irks me is that if I create a vanilla addin (also via the Wizard) then when I install and load Outlook, the path returned is correct. It's only when I try and use my existing project that it returns the wrong path.
I even tried creating a completely new project and then cut-n-pasting the code from the old project into new class files since I wasn't sure if the registry has got "bunged-up" with invalid/old entries. I have noticed that when VS2003 registers the addin for COM interop it will create registry entries that have a CodeBase value that points to the build .dll file (which is pretty obvious since at that point it hasn't been installed!). However for the vanilla project it must do something similar so I don't think that's causing the problem.
Anyone any ideas on how I can stop/correct this problem? It's driving me nuts
Thanks (in advance),
Gary
P.S. The addin did "do the right thing" in the past but I changed the ProgId value and then everything went belly up...
|
|
|
|
|
I've found a way out of this little mess...
The way to do this seems to be to get the MS installer to create a registry item with the install path when it does the install.
To do this just set the value of the item to [TARGETDIR] the square brackets are important and it's case sensitive. (More info on the installer properties can be found at: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/msi/setup/property_reference.asp)
The installer will then replace the [TARGETDIR] with the directory that the COM addin was installed to.
Given some of strange things (i.e. things I don't understand at the moment ) that the .NET framework will do for assembly loading this seems to be a more reliable method.
Gary
|
|
|
|
|
I found a link in CodeProject about creating notification and time application. The source codes included is build from scretch which is too confusing to me. Anyone know any easier way to make a reminder notication in Pocket PC. Thanks for reply.
|
|
|
|
|
Hi all. I need to find a signature block in a scanned document. I can create the document so I can put a box around the signature or mark it in some way. I just don't know how to find it. I don't think I can depend on it always being in the same spot. Any ideas?
|
|
|
|
|
Depends on what a 'signature block' is. Obviously, because it's scanned, you can't depend on it being pixel for pixel exactly what you expect, or even to be rotated 100% correctly. You'll need to do some fairly complex pattern matching. Edge detection would be a good place to start, to simplify the image you're dealing with, assuming this won't lose detail that you need to find.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
If you are developing commercial solution then we'd glad to hear from you.We have developed formsProcessing software for one of our clients in US.
Regards,
MaulikCE
maulik.modi@gmail.com
|
|
|
|
|
Hi all.
I'm not sure if this is the right forum for this. If it's not, I'm truly sorry. I have a couple of questions regarding Whidbey (VS.NET 2005) Beta 2.
1. Is it safe to install it on my production machine? Working in a Virtual PC is a PITA. It would be installed side by side with VS.NET 2003. Horror stories? Tips and tricks regarding this?
2. Say I reference an assembly (ie: 3rd party component) that was compiled with .NET 1.1 in a .NET 2.0 project. Will this 1.1 assembly run against the 1.1 or 2.0 framework? Is it safe to reference v1.1 assemblies?
3. When I install the .NET Framework 2.0 on a clean machine (ie: no .NET 1.x installed), does it also install v1.0 and v1.1 of the framework? Say the answer to question #2 is that it runs against version 1.1 of the framework, am I required to install BOTH versions of the framework on my customers machines?
Thanks a lot for your help!
|
|
|
|
|
1: I am doing this ,and it's bretty fine .
2: It will convert it to the appropirate version and use the .Net 2.0 to run it. AS FOR EXAMPLE : (Any .NET 1.0 application runs clearly on .NET 1.1).
3: No,2.0 will be enough to run any VS2005 application .
|
|
|
|
|
Hi,
Thanks for your answers.
However, I'm not sure you understood question 2 and 3 correctly. I meant, if I reference a DLL assembly that was compiled with version 1.1 of the framework in a 2.0 application, will the DLL run against v1.1 or v2.0?
Thanks!
|
|
|
|
|
That will depend on if your assembly was specifically built to target 1.1. By default, it targets the most recent framework version on the machine, I believe, so regardless of if it's referenced in your project, it will run under 2.0 on a 2.0 installed machine. You can set it to build so it requires 1.1, though, and then it would run under 1.1, because you told it to.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
I've just been to a Microsoft MVP conference where my focus was on Whidbey sessions. Microsoft say it will be fine when they release it, and should be fine now, but they don't recommend it. I personally run it next to 2003 on a non dev machine ( a notebook I use to play around with stuff ). I would never install it on a production machine while it is in beta.
The whole point of the framework targetting is that you can explicitly target a framework version, and then it will always use that version.
I don't believe it installs 1.0 and 1.1, no. Yes, if you have a component that requires 1.1 for some reason, you'll need to install both on a client machine. If you wrote the component, run your regression tests against a build using the new compiler, and then move to 2.0. If you don't have regression tests, have some next time you build something.
You can get a licence from microsoft to distribute 2.0 code and the framework, but it requires you to replace all installs of the beta framework in the wild with the full version within months of the release date. I wouldn't do that unless you have to.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for that info Christian!
Our release is set for October or around that time. 2.0 final should be right around the corner by then.
What's the lastest temptative release date for .NET 2.0? Do you know? Of course, "nobody knows for sure", but what are they aiming for? Can we expect it for oct/nov you think?
There's a running joke that says December 35, 2005
Have a good evening!
|
|
|
|