Transaction script is Antipattern?

Transaction Script is definitely not an anti-pattern. From what I find about Transaction script, it is not object-oriented at all. You are right, it is not, indeed. That fact however doesn’t make it an anti-pattern. Although it is a procedural approach, indeed, it still has its right place in the series of business logic architecture … Read more

Should I use public or private variables?

private data members are generally considered good because they provide encapsulation. Providing getters and setters for them breaks that encapsulation, but it’s still better than public data members because there’s only once access point to that data. You’ll notice this during debugging. If it’s private, you know you can only modify the variable inside the … Read more

How can I generate database tables from C# classes?

It’s really late, and I only spent about 10 minutes on this, so its extremely sloppy, however it does work and will give you a good jumping off point: using System; using System.Collections.Generic; using System.Text; using System.Reflection; namespace TableGenerator { class Program { static void Main(string[] args) { List<TableClass> tables = new List<TableClass>(); // Pass … Read more

Can I have an optional OUTPUT parameter in a stored procedure?

Both input and output parameters can be assigned defaults. In this example: CREATE PROCEDURE MyTest @Data1 int ,@Data2 int = 0 ,@Data3 int = null output AS PRINT @Data1 PRINT @Data2 PRINT isnull(@Data3, -1) SET @Data3 = @Data3 + 1 RETURN 0 the first paramter is required, and the second and third are optional–if not … Read more

Saving multiple objects in a single call in rails

Since you need to perform multiple inserts, database will be hit multiple times. The delay in your case is because each save is done in different DB transactions. You can reduce the latency by enclosing all your operations in one transaction. class Foo belongs_to :parent, :class_name => “Foo” has_many :children, :class_name => “Foo”, :foreign_key=> “parent_id” … Read more