code-reuse

Errors: “INSERT EXEC statement cannot be nested.” and “Cannot use the ROLLBACK statement within an INSERT-EXEC statement.” How to solve this?

浪子不回头ぞ 提交于 2019-12-17 02:09:14
问题 I have three stored procedures Sp1 , Sp2 and Sp3 . The first one ( Sp1 ) will execute the second one ( Sp2 ) and save returned data into @tempTB1 and the second one will execute the third one ( Sp3 ) and save data into @tempTB2 . If I execute the Sp2 it will work and it will return me all my data from the Sp3 , but the problem is in the Sp1 , when I execute it it will display this error: INSERT EXEC statement cannot be nested I tried to change the place of execute Sp2 and it display me

Big picture or guide on programming related topics?

…衆ロ難τιáo~ 提交于 2019-12-13 05:40:27
问题 I was wondering if someone could give a big picture of how the following topics and others not mentioned are related: "code reuse" "refactor" "design pattern" "coding/programming standard/style" ... I have heard of these from people's talk and books' names, but got overwhelmed by these names. May I get some organization and big picture from here? Thanks and regards! 回答1: I think you need to buy a copy of Dave Thomas and Andy Hunt's "The Pragmatic Programmer". There are plenty of other good

Using System.Attribute class

≯℡__Kan透↙ 提交于 2019-12-13 03:08:07
问题 I got myself in a situation where using the System.Attribute class seemed (at first glance) to be a good idea. I have an object to be printed in my application, and I need a label before each property (or just a string before it). I could put each property hardcoded like: Console.WriteLine("Color:"+obj.color); Console.WriteLine("Size:"+obj.size); And so on for each property. But instead of it, I was trying to create a code where this 'label' doesn't needed to be hardcoded, so I could print

ASP.NET MVC - Reusing Action Behaviors

坚强是说给别人听的谎言 提交于 2019-12-12 15:11:49
问题 This question pertains primarily to good design. Suppose I have a controller action like DeletePage that can be invoked in two separate views of the same controller. Assuming the delete logic is not contained in the action itself, but rather some conditional checks and the like that call the correct business logic, it doesn't make sense to duplicate the structure of the delete action when I can instead have a private method that returns an ActionResult which I call in both actions which can

how to adhere to the Don't-Repeat-Yourself (DRY) principle when there will be too many if-then-else making the code unreadable?

无人久伴 提交于 2019-12-12 10:17:04
问题 I'd like to adhere to the Don't-Repeat-Yourself principle, but sometimes when I write PHP together with HTML and CSS, if I re-use the same code for different situations, my code soon will have so many if-then-else that the code is not easily maintainable. This may be a bigger issue if Smarty, the templating engine is used, because most code editor won't match up {if} {else} {/if} So the programmer needs to look for the matching tag visually, and is not easy when there are 3 or 4 levels of

How can I reuse classes in my VB6 application?

≯℡__Kan透↙ 提交于 2019-12-11 18:45:31
问题 First of all, as I am using VB6, please confine your kind suggestions to techniques applied to VB6. I have a set of controls related to each other as the above figure shows. It includes several treeviews, a split bar, a listview, a subform( a usercontrol), and etc. When I click or change the treeview nodes in the left, the right controls will change their display accordingly, and vice versa. The data behind the scene is maintained in an Access database. This set of data management and display

Global variables for setting configurations ASP.NET MVC

核能气质少年 提交于 2019-12-11 15:32:47
问题 I wanted to define a global variable in ASP.NET MVC project which will have static configurations details. Like context name, project name etc. Actually I am working on developing reusable component for which you can set all these variables and include them in the project such that they work. Just to give an example using PROJECT_NAME.Models; using PROJECT_NAME.BizLogic; PROJECT_CONTEXT db= new PROJECT_CONTEXT; and rest of the code follows This way if I code the components, I think I can use

Reusing symbol table from semantic analysis phase for code generation

大兔子大兔子 提交于 2019-12-11 11:17:40
问题 I'm currently building a compiler for a language which has global variable and nested subroutine feature. Previously, I've only ever built a compiler for languages which only has local variable without nested subroutine. I have a problem on how to reuse symbol table filled during semantic analysis phase in code generation phase. I make the symbol table as a stack of linked list, where each linked list represents identifiers declared in a particular scope. Every time it enters a scope, a new

Re-using set of model fields in Django

こ雲淡風輕ζ 提交于 2019-12-11 06:46:33
问题 My site has two types of users; customers and suppliers. I have ended up with the following class structure: class Customer(models.Model): # stuff specific to customers class Supplier(models.Model): # stuff specific to suppliers class Profile(models.Model): # returned by Django's User.get_profile() user = models.ForeignKey(User, unique=True) customer = models.OneToOneField(Customer, null=True, unique=True) supplier = models.OneToOneField(Supplier, null=True, unique=True) Now I need to add

PHP Class Database Connection Scope Issue

痴心易碎 提交于 2019-12-11 04:22:48
问题 For a new project that I'm doing in PHP I've created an SQLMethods class to connect to the database and perform queries. Tonight was the first night that I actually got to test it (I wrote it a week or so ago and forgot about it) and an unexpected error occured: When it was calling my ExecuteQuery() function, it wouldn't use the database I selected in the constructor. The constructor: public function SQLMethods() { $SQLConnection = mysql_connect($SQLDBAddress, $SQLUserName, $SQLPassword); if