Object Oriented Design: Is it good to restrict I/O parameters?
I am designing a system for Social Activity Streams and I am aiming to keep it independent and plug-able as much as I can. Since it is about Activity Strams so here is the initial design. I am willing to use Strategy Pattern since it would have different types of activity streams.
public interface IStreams
{
public int add();
public int delete();
public int edit();
}
Now I am going to implement it, Here is the code:
public class TypeOneActivityStreams implements IStreams {
public add()
{
}
}
Now I want that the consumer of my class must follow I/O parameters because if he does not then obviously values will not insert in开发者_如何学C Db. Now what kind of parameters and return type should be. Should It be an Object or an Array?
Thanks
Update: I am using RDBMS to store stream related data in database and that db structure would be quite isolated with systems who will be using this Activystreams system.
I'm not sure if this answer will be of any use (because I'm not sure if I understood the question correctly), but you might use DTO. On one hand, it would allow you to pass different sets of parameters in various implementations of IStreams, as you may have different implementations of DTO (i.e., different DTO with different sets of attributes). On the other hand, if you write an interface for DTO, you could specify that input parameters must be a DTO.
精彩评论