|
I have something brewing in the back of my mind for sharing the tables that populate common drop-down lists, along the lines of a singleton 'list provider', or at worst, a shared DataSet with tables for lists, populated on demand. I'd just like to know if there are any other patterns for doing this.
Example, many of my forms have the same Product dropdown, so I'd like to factor out the information shared by each instance of the list, i.e. the stored proc name, or query, and the display and value field names.
|
|
|
|
|
Brady Kelly wrote: a shared DataSet with tables for lists, populated on demand.
What does populated on demand mean? Lazy Initialization?
Brady Kelly wrote: so I'd like to factor out the information shared by each instance of the list, i.e. the stored proc name, or query, and the display and value field names.
I don't understand, are you not using DataBinding? You can bind as many controls as you want to the same DataSource. I have no idea what you are trying to do.
led mike
|
|
|
|
|
I'm trying to remove the 'how to knowledge' for populating value-text lists from the clients of those lists, as my e.g: I use a Product drop-down on several forms. I don't want to duplicate the code to populate the product list in each place I have a product drop-down.
|
|
|
|
|
Brady Kelly wrote: I don't want to duplicate the code
What code, you set the DataSource property etc.? If you want to go to the trouble of creating a custom control then you can use it on all your forms. Having the same drop down list on multiple forms sounds like poor UI design anyway. Oh wait, this is a Browser application isn't it? Never mind.
led mike
|
|
|
|
|
I'm trying to move toward something like a 'list service', from which I can request a list by name, e.g. Product, and get a list of products suitable for a drop-down. This is for both browser and winforms applications. Then all I need to is set DataSource to my list, which is somewhat standardised, i.e. it always has a Value property and a Display property.
|
|
|
|
|
Well, you could always use a Dictionary for this - possibly stored in the Cache for you web site (and static for the winforms). The dictionary would be of type string and List, where you would retrieve the list based on it's name. It's not an elegant solution and just screams quick and dirty hack to me, but it should work.
|
|
|
|
|
I'll look at using the cache, but I don't think it would be too much of a performance hit to reload the lists for each initial page access. I prefer a stateless approach, and it's the means of loading the lists I'm trying to abstract away more than the actual storage and or lifetime of the lists.
|
|
|
|
|
Brady Kelly wrote: and it's the means of loading the lists I'm trying to abstract away
Brady Kelly wrote: sharing the tables
Aren't database and tables already abstracted? Are you not already using something like a DataSet or whatever that abstracts the whole Database query table stuff?
led mike
|
|
|
|
|
No, it's DataSets and whatever that I'm investigating, the whatever a bit more, as DataSets are already known and even featured as on option in my OP.
|
|
|
|
|
I just did something like this for my current project. I created a class with a shared (static) dictionary which contains the dropdown lists. There is also a shared method which is passed the name of the desired list. The method checks the dictionary first and then queries the database if necessary. It's really just a simple data caching class. Not sure if this is considered the "proper" way to do things (I'll leave that to the programming gurus out there) but it's easy to code and it reduces the number of database calls..
Hope this helps,
Joe DiNatale
|
|
|
|
|
Joe DiNatale wrote: Not sure if this is considered the "proper" way to do things
Depends. Did you make that optimization after running a profiler and determining that it was needed?
"premature optimization is the root of all evil." (Knuth, Donald - 1974)
Joe DiNatale wrote: It's really just a simple data caching class.
Do you have any idea how many caching mechanisms already come into play when making database calls? It is entirely possible that your solution slowed down your process.
led mike
|
|
|
|
|
I'd be inclined to use something that does caching properly. Otherwise you'll end up with annoying bugs, like products being added, and your dropdown lists won't show the new products until the worker process is recycled.
If your pages are going slow because of many database round trips, then consider using asynchronous pages.
|
|
|
|
|
Hi All,
I have a dll A which contains functions f1, f2, f3, and i use these functions in my application, say function f4 in my application uses them for some purpose, now the problem is dll A is from third party, and it can have multiple versions in the future?, how can i take care of this issue in my design of Application such that new version of this dll(new version may have more functions or changed function names) doesn't impact function f4, say if new version dll is just extension to previous dll, would it be automatically called by my app, or do i need to take some measure to support new version, please help by considering other similiar scenarios, if i have missed any?, Thanks in Advance!
_____________
princenrj23
|
|
|
|
|
If its a proper, published interface API then future releases should be backwards compatible. There is no guarantee of course, but no respectable company would replace a function with another of the same name that did something totally different. For example, in version 1.1 fuuntion F1(int a,int b) returns a + b would never be replaced with funtion F1(int a,int b) that subtracts them, it just isn't done.
That said, it should be standard practice to regression test whenever you are considering using a new version of any software.
Hope this helps
Bob
Ashfield Consultants Ltd
|
|
|
|
|
It has become increasingly popular to implement Delete functions in such a way that the user will not be bothered with MessageBox confirmations, but will instead be given the option to undo his action. Gmail does it, and this is covered very well in an article at alistapart.com[^].
I've been implementing this in my own projects, and would like some input from others regarding the best design for this. In many cases, the implementation isn't terribly complex: When an entity is deleted, it is simply deleted from a table, but a copy of the deleted entity is stored on the side (for instance in ViewState if this is a web application) and the user given the option to undo his action. If the user chooses to undo, this entity is simply re-inserted into the table. If the user doesn't choose to Undo, this copy will simply get lost when the page is closed, which is very much in line with the user experience (when he closes the page he will probably expect to loose the chance to undo his action).
As I said, this might be OK under some circumstances. But then there are others. For instance, lets assume I'm writing my own blog site, I want the admin to be able to delete blog entries, and I want to implement undo as well. Each blog entry has a unique ID allocated by the database, each blog could then have zero or more comments, where each comment could be linked to another comment (similar to the messages in the CP messageboards). This would be implemented such that each comment has also a unique ID (assigned by the DB), each comment has a BlogID and a ParentCommentID. Blog posts are then linked to using their ID (myblog.com/Blog.aspx?ID=10). Let's assume that the admin now wants to delete a blog entry. By using the implementation given above, several problems arise. First, if the admin chooses to undo the deletion of a blog entry, a new entry would essentially be created, so the BlogID's of each comments would have to be updated. Also, comments would have to be relinked together since each comment would also receive a new unique ID, so all the parent ID's would have to be updated. Both of these tasks are very well manageable, but annoying. However, the biggest drawback lies in the fact that any links to this post are now invalid, since the blog entry wasn't really undeleted, a new one with the same content was created but with a new ID. So this implementation doesn't guarantee that the system is in the same state as it was before the delete/undo combo.
Another implementation could be like this: When an entry is deleted, it is in fact not actually deleted, but instead marked as deleted (this requires a new column in the table, and it requires all get-queries to be rewritten so they don't fetch deleted entries. Again: a bit annoying but perfectly manageable). This means that Undo is much simpler: it simply removes the "Deleted" flag from that row. But the question remains: when is the record actually deleted? Should we maybe not bother with it? Should we implement an "Empty trash" function for the admin as well? And should we implement undo for that as well?
As you can tell I have a LOT of questions. Feel free to answer as many or as few as you like I'm basically checking if I'm missing something obvious, or if anyone has given something similar any thought.
Bottom line: how do you implement Delete/Undo in your (web) applications?
Wenn ist das Nunstück git und Slotermeyer? Ja! Beierhund das oder die Flipperwaldt gersput!
|
|
|
|
|
dabs wrote: would like some input from others regarding the best design for this
Your not asking about design, you are asking about what feature should be implemented. That question needs to be asked for each project based on the project definition.
An admin deleting threads and all it child replies is not at all equivalent to someone deleting text in a word processor.
For this reason I don't believe the Undo is a good fit. A recycle bin where it must be manually deleted or perhaps expired but until then can be restored sounds like a much better use model for an Administrator and that problem domain.
led mike
|
|
|
|
|
Hi,
I've been searching the web for months but although there is a lot of stuff to find about sockets between client and server, I've found very little on designing a protocol to talk over this socket.
For what i need (basic question/response and synchronizing data, which i currently do using xml), there is little to find. And so i learned a lot of hard lessons involving recoding a lot of the app due to stupid errors which i did not forsee due to lack of experience.
Does anyone know some sources for more information about this subject or have a view on protocols for client/server apps? It's my first Client/Server application and I feel like i am in the dark.
|
|
|
|
|
A 'Protocol' is nothing more than an agreed upon conversation.
When you walk up to someone and say hello and expect a hello in response you have a protocol.
You are free and open to do what you want really but since you are shuffling files back and forth perhaps you want to look at an established file transfer protocol. Loop up RFC 959 for FTP[^] and start reading.
|
|
|
|
|
Hmm.. I understand that. Seeing I come from a system administrator background I have enjoyed reading a couple of the RFC's in the past
However: I am not transmitting files over the socket.
The actual question is: are there gotcha's in protocol design (for instance i found out that having an <eof> parameter to let the client detect when the command is done is an abolute must).?
|
|
|
|
|
Noctris wrote: are there gotcha's in protocol design (for instance i found out that having an parameter to let the client detect when the command is done is an abolute must).?
Not sure what that means.
Noctris wrote: It's my first Client/Server application and I feel like i am in the dark.
Not unusual, it's a large subject.
Noctris wrote: I've found very little on designing a protocol
Yeah I don't remember ever seeing anything like that. Try looking at existing protocols rather than looking for something that teaches protocols. I suggest you start with some simple application level protocols like HTTP/FTP/POP3 of course...
Noctris wrote: what i need (basic question/response and synchronizing data, which i currently do using xml)
That sounds like SOAP so you may not need to create your own protocol. It's difficult to say for sure with the limited information you provided.
led mike
|
|
|
|
|
Hi!
I'm looking for an approach for creating server data presentation (input) on client side.
I have a client application (Delphi) and server application ASP.NET.
Server can get different set of data (text, date, true/false etc).
Server can change required data set and than client should react on that change by changing controls for server data presentation.
So the question is: Are there any approaches or existing technologies to support such client-server interaction.
I suppose that it may be done via some intermediate user creating language in some xml format for example. But there are many others questions in such an approach:
How to create control events handling routines? (For example validation, etc)
|
|
|
|
|
I don't find any question in your post related to your subject line. You seem very confused about pretty much everything. I suggest that an internet forum is the wrong format for solving your problems. You need some good books or something.
led mike
|
|
|
|
|
Hi,
I've been coding in .NET and Java and C++ for a few years now and I still haven't
quite got my head round Association ,Aggregation and Composition.
I know a the difference conceptually, eg. A Bank *has* branches (Aggregation), eg. A Child *has* a toy (Composition).
The thing that confuses me, is when it comes to coding the relationship.
I've looked at examples on the Web and it still confuses me.
C# and Java
public class Boy
{
public void PlayWith(Toy toy) {toy.play();}
}
public class Bank
{
List<branch> branches = new List<branch>(2) {new SydneyRdBranch(); new ParisRdBranch(); }
}
</branch></branch>
Please could someone explain how to write Association, Aggregation and Composition in Code please.
Many Thanks
Tom
|
|
|
|
|
AFAIK association encompasses both aggregation & composition, the difference between composition and aggregation is that with composition when the containing object goes out of scope then so is the composed object for example a car is composed of an engine once the car goes out of scope the engine goes with it.
In contrast aggregation means that the even when the containing object goes out of scope the aggregated object still remains for example a car could have a driver if the car goes out of scope this doesnt mean that the driver object will.
It really boils down to whether the object in the contained object is created inside or passed in, your Boy example is Aggregation as the Toy is passed in, and the Bank example is composition as the Branches are created internally
hope this helps
|
|
|
|
|
Just explanaing further..
Toy example is Aggregation.
As Toy instance is created out side the scope of Class Boy. So deletion of object of Boy will not make impact of object of Toy.
Bank has composition relationship with BankBranch.
Since instances of BankBranch created inside scop of class Bank so if object of Bank goes out of scope then objects of BankBranch will be get deleted (destructor of Bank must be delete objects of BankBranch)
Akash
|
|
|
|