|
UI controls, whether the main form or the User Control is just a mechanism to allow a user to interact with the underlying. What I do not understand is why you want the user control to enable/disable main forms controls: They must know about each others controls and adds to coupling which is not ideal. If you want a menu item to enable/disable based on customer's last day or whatever, then have both the main form and the user control subscribe to the customer. UserControl will do what it is supposed to do and main form will do what it is supposed to do. Now these UI elements only know about the "thing", in this case the Customer, they are displaying but not about each other.
It will be like this: Customer is loaded and obviously properties will change, then the UI Control will subscribe to an event from customer--you have to create the events based on your requirements. In this handler, the control will ask the customer for whatever it is interested in, for example, IsLastDayOfStay, if true will enable itself and false otherwise. The main form will also subscribe, and ask for something else and mold itself accordingly. You can also design it so the form does not need to ask the Customer, but the event arguments can have the information in it. For this, you would need to create a simple class to encapsulate even arguments.
The only problem is the controls are tied to your object.
If I am not understanding what you want to do, then just write in plain English with no code what it is you want to achieve and hopefully I or someone else can give you a suggestion.
|
|
|
|
|
I kinda understood what your saying better after looking at paint.net source code lol! I've been looking at a lot of programs like that for inspiration.
So the Main form code itself should decide what menus and toolbars need to be enabled/disabled by querying/using business objects itself? That would be a correct design? (Atleast thats how it is in Paint.NET)
(I'm sorry if i sound daft from time to time, I'm young and not formally computer educated!)
|
|
|
|
|
I'm looking for a tool where I maintain a simple data model, and then using possibly plug-ins, generate actual databases for MSSQL and mySQL, and as a bonus, others. This should not be a whole ORM tool, just abstract to concrete data model. Where should I look? Who knows of one?
|
|
|
|
|
|
Hi Brad
Please don't pre-judge ORM solutions. With good engineering concepts and common sense you can take a good approach with this point of view
I invite you to visite our solution at www.codeplex.com/circo (not a ORM from books but form the experience of engineers who needs to struggle with diferent customers, clients, languages an programming cultures)
I hope you find useful this ideas and esentially the implementation
Regards
|
|
|
|
|
Very often it is advantageous to invoke certain validation logic on client and server, especially if they are not always connected, or if another, uncontrolled client uses the server. I mean less of the simple validations, such as 'Surname must be present', although I don't exclude that, but rules such as a document billed date should generate a warning if more than thirty days before or after the current day.
A ideal solution would be one server validation engine that receives client requests to check single rules, or even a collection of rules, before the more expensive submission of the whole document. Some constraints, such as minimising server requests, or allowing the client to perform a validation and local saving of a document while disconnected, exclude this solution.
A possible solution after that is to use the same validation library on client and server, which has the advantage that additional, external clients could also make use of that library. One happy family, all using the same properly designed, implemented, and tested library.
The biggest, and in my opinion, most common problem with this is with web applications. Validation code on web pages is normally done in JavaScript, or a higher order JavaScript library, where the server validation code is written in C#, VB.NET, Java, etc. This means the validation code cannot be shared, but must be separately implemented in another language, probably by another coder. Both this language and this coder handle things differently to the combination that developed the server side validation library or routines. This means maintenance to validation code must be done in two places, and in two languages, on two platforms, and for me, only two variants of this code is slightly optimistic in some cases.
Last modified: 12mins after originally posted --
|
|
|
|
|
Hi,
I'm learning how Silverlight/WPFapplication/Direct3D interact between themselves...
Sorry but I haven't a lot experience about this issues, so my question is:
- IS IT POSSIBLE, WITH SILVERLIGHT, TO RENDER WPF FILES IN A DIREC3D/WIN32 APPLICATION? HOW CAN DO IT?
Thanks a lots,
bye,
Carmelo.
|
|
|
|
|
You are Posting in a Wrong Place , go to Silverlight Forum, i think i saw your Qustion somewhere ,Stop Cross Posting
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
What is the best way to structure class objects in a program that allows me to search for values from different properties of the class?
I am making an application that holds client name, address phone and note information. I created a Client class that holds all these together. In my main program, I was putting each new client in an array list, but I ran across a problem. I can't search my array list for just a first or last name.
I don't think that overriding the Equals function of my class would allow me to change that, so I started looking at other ways to hold my data.
If I created another value in my class, like an ID field, I could create a hash table that was a ID/value pair (ID/First Name, ID/Last Name, ID/Address, ect). This would allow me to search each hash table and find the ID to get the full record, but that would mean I would need a table for each field that I would want to search. At this point, I'm a bit stuck on the best way to set my data structure up.
If there's some articles that give some guidance and suggestions, I would appreciate it. I can't seem to find anything because I don't think I'm using the right terminology.
|
|
|
|
|
hpjchobbes wrote: but that would mean I would need a table for each field that I would want to search
Consider this the way that DBs do it. That is (at a high level) what gets created when you form an index on a table. That's why you really should not go and create indexes on every attribute of an entity.
One thing you could consider doing is instead of storing the data in an array list of objects in memory, store it in an in memory data-set. That way you can query it using standard SQL queries all you want. Wrap the collection in a class that uses an data set internally to store the data and returns collections of objects to you as the result. That way you can keep your data in a simple search-able format and still get objects to work with latter.
I am sure that someone here could also come up with some cool alternatives using objects and LINQ, but I am not all up on that tech yet
|
|
|
|
|
I'm just starting to learn programming, so I was trying to keep my implementation simple, but I guess this is a bit more complex problem that I originally thought! I guess for my simple application having a hash table for each field is probably the easiest way to go.
I didn't even think of making my own collection class, but that seems like it might be a good way to go to learn more about databases before I start diving into some of the main databases out there. I'm not to the point where I need to worry about handling large amounts of data, so for now, I'll keep it simple.
Thanks for the information!
|
|
|
|
|
keeping it simple is always good, just build it so that you can extend it latter without having to redo too much of the host application. Always be thinking about encapsulation, even when trying to keep it simpler.
Things have a way of getting away from you and not staying simple for long
|
|
|
|
|
Overriding Equals is only for comparing if objects are the same.
Ignoring indexes, if you need to search a List< Person> then you can do it by hand. Iterate over the list with foreach, and put the results into your result list when the fields match. If you are using a later version of the framework you can pass an anonymous method into the .Find(Predicate< T>) method. This would look like this:
List< Person> results = data.Find(delegate (Person p) { return p.Name == searchName; });
Or in a lambda expression:
List< Person> results = data.Find(p => p.Name == searchName);
If you are just starting programming then worry about the basics first. As for indexing, you should either use a database (Diamond Binding in my sig will make it pretty easy for you) or if you want a pure object solution then you might want to check out a pure object database. db4objects is a very good object database, but can be quite expensive. Generally in the "real world" you would rarely be writing your index code by hand (but it is important to be aware of lookup performance in your data structures).
|
|
|
|
|
Thanks for the response! The .Find(Predicate<t>) function is interesting and I'm going to be looking into that more. All my programming is really for learning purposes, so I tend to try and stay away from solutions that have been built for me as I don't feel that I get a good understanding of what is going on. It's probably not the 'best' method for learning, but it seems to work decent for me.
What I just thought about now, seeing you mention using List<t> instead of ArrayList is how the two differ. I would imagine that ArrayList just boxes everything into an object, where List uses the base type. Would this make it faster to search through a List than an ArrayList as there is no need for un-boxing? I guess there's another topic added to my list of things to research!
Thanks for the information!
|
|
|
|
|
Yeah theres a bit of history there. List< T> is a generic list, which means when you use say List< Foo> you have effectively created a brand new type out of thin air, a List of Foos. Before framework 2, generics didn't exist in the runtime, and ArrayList was a provided and the commonly used IList implementation.
Both are implemented the same under the hood, they both wrap an array which they resize as necessary. For new development you may as well use List< object> over ArrayList, they are functionally identical, but using List< object> makes it very clear that you know the generic class exists - and thus the list is actually full of random crap.
I guess the generic list would remove any unboxing that happens, I had never really looked at it that way (it would definitely help with the semantics of having to do foo = (long)(int)objectWhichIsReallyABoxedInt).
As you learn programming you will hear a lot of people talking (mostly crap) about optimisation. Generally speaking you should look out for the big-O order of things, and obvious problems like doing a bunch of high-latency things in serial. Most things like "avoiding boxing", "avoiding reflection" make little difference to a real world application. In fact I've seen a great many "tips for faster code" that results in identical IL (and thats before JIT optimisation). I use reflection extensively in Entanglar (even in the renderer I'm working on), and the performance of that is more than acceptable.
|
|
|
|
|
|
What if you did something like this:
Create a class called ClientCollection which will have all the clients in some data structure of your choice. Within this class (ClientCollection) have a method called Search, or Find which will take 2 parameters: 1. The property to search by and 2. The value to search for. Within this method create a Dictionary and put all your clients into it. The property to search by will be the Key, and the value will be the Clients. Afterwards, call the Contains method of the Dictionary to search the value passed in.
Of course, this means that if you have many clients putting them into the Dictionary will take time.
I will also do what you suggested above in addition to this but create tables for the field(s) which will be used mostly for searching.
Now you don't have too many tables, but you are also providing the flexibility of searching by any field.
|
|
|
|
|
Hi folks, i'm relatively new to this area of things although i have been using C# for many years. I have been trying to find a starting point for organizing my code for medium sized projects. What i am after is a relatively detailed example of how a software application solution would be organized in Visual Studio. For example if i worked for company CMP and had an application i wished to create named AppX, no doubt i would start with a solution named: CMP.AppX .. and then begin adding projects. I am aware that every situation would be different and would require different projects and namespaces, but i would like an example of how you guys would go about doing it and some reasons for your choices. eg:
CMP.AppX
CMP.AppX.Data
CMP.AppX.UI
CMP.AppX.UI.Desktop
CMP.AppX.UI.Web
CMP.AppX.Webservices
CMP.AppX.UnitTests
CMP.AppX.Reporting
...and how this would be achieved - what was a project and what was subdir in the project folder etc. Thanks in advance.
|
|
|
|
|
We organize our projects normally in this way:
1)
One solution for all projects we are currently developing. Developing with several solutions at once is very cumbersome.
2)
However, if there are components that can be extracted in some sort of library or framework then do it (only feasable for components that can be developed independently for the most part, because of 1)
3)
If our system is built up from different "sub-systems" (sometimes there is a relationship with tiers, but it's possible to have either several sub-systems per tier or viceversa) then we arrange them within solution folders (note that solution folders are virtual folders and that there are no folders in file system for them).
4)
We try to keep the number of projects limited because a large number of projects has a negative effect on build performance. Therefore we wouldn't arrange our project the way you suggest in your post (propably). Keep in mind that assemblies are a deployment unit, nothing else. There is no problem in packing several components into a single assembly, as long as they are deployed together. Requirements on releasing individual components can however be a reason to seperate components into different assemblies.
5) For each project we habe an additional unit test project to seperate the tests from production code. We use a naming rule: for project MySystem.MySubsystem.MyWhatever.dll exists a MySystem.MySubsystem.MyWhatever.Test.dll. This simplifies out NAnt script for building, testing and releasing our software.
6)
Namespaces are hierarchical and should be used in this way. That means that we express abstractions with namespaces. E.g: MySystem.MyComponent contains everything that is used in that component and MySystem.MyComponent.MyImplForCaseX contains the details for a specific extension while the code in the subnamespace can access the content of its parent namespace.
This results in very little access to sibling or child namespaces, thus supporting loose coupling of components.
7)
We use subversion as version control system. With the following structure (this is however really project specific):
root/
trunk/
doc/
source/
libs/ contains all 3rd party dlls our projects reference, built up with svn-externals and real dlls
scripts/ contains all NAnt scripts for building, unit testing and releasing
tools/ tools used for building etc.
releases/
Release 1.0/
[trunk/] only if release is modified (bug fixes)
[releases/] "
That's all I can recall on a Sunday Morning
-^-^-^-^-^-^-^-
no risk no funk
|
|
|
|
|
|
Hi,
Can anyone suggest how to design application, which support multiple databases (like SQL Server, Oracle) and with minimum change, we can shift database from one to another.
Thanks.
|
|
|
|
|
Colin Angus Mackay has nice series about building DAL that supports multiple databases. Swithing from one database to another is a matter of changing configuration file so you don't need to recompile application. You can find the first part here: What is a DAL? [^]
|
|
|
|
|
With most OR mappers this is a change in the configuration file.
Yes, yes I know, if you have performance optimizations in your code, then it's not that easy
-^-^-^-^-^-^-^-
no risk no funk
|
|
|
|
|
|
heyitsAtul wrote: Hi,
Can anyone suggest how to design application, which support multiple databases (like SQL Server, Oracle) and with minimum change, we can shift database from one to another.
Thanks.
It can be done in several ways. First of all you need to have an abstraction layer. That layer needs to be a generic layer that matches the interface for both databases. Secondarily, I'll recommend that use a factory. Try to take a look at the following link for inspiration
Connection pool[^]
Hth
--
Jess Nielsen, b.sc.
Security Analyst
http://jessn.blogspot.com/
|
|
|
|
|