Search Results

Search found 4704 results on 189 pages for 'refactoring databases'.

Page 20/189 | < Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >

  • Data layer refactoring

    - by Joey
    I've taken control of some entity framework code and am looking to refactor it. Before I do, I'd like to check my thoughts are correct and I'm not missing the entity-framework way of doing things. Example 1 - Subquery vs Join Here we have a one-to-many between As and Bs. Apart from the code below being hard to read, is it also inefficient? from a in dataContext.As where ((from b in dataContext.Bs where b.Text.StartsWith(searchText) select b.AId).Distinct()).Contains(a.Id) select a Would it be better, for example, to use the join and do something like this? from a in dataContext.As where a.Bs.Any(b => b.Text.StartsWith(searchText)) select a Example 2 - Explicit Joins vs Navigation Here we have a one-to-many between As and Bs and a one-to-many between Bs and Cs. from a in dataContext.As join b in dataContext.Bs on b.AId equals a.Id join c in dataContext.Cs on c.BId equals b.Id where c.SomeValue equals searchValue select a Is there a good reason to use explicit joins rather than navigating through the data model? For example: from a in dataContext.As where a.Bs.Any(b => b.Cs.Any(c => c.SomeValue == searchValue) select a

    Read the article

  • Pattern or recommneded refactoring for method

    - by iKode
    I've written a method that looks like this: public TimeSlotList processTimeSlots (DateTime startDT, DateTime endDT, string bookingType, IList<Booking> normalBookings, GCalBookings GCalBookings, List<DateTime> otherApiBookings) { { ..... common process code ...... while (utcTimeSlotStart < endDT) { if (bookingType == "x") { //process normal bookings using IList<Booking> normalBookings } else if (bookingType == "y") { //process google call bookings using GCalBookings GCalBookings } else if (bookingType == "z" { //process other apibookings using List<DateTime> otherApiBookings } } } So I'm calling this from 3 different places, each time passing a different booking type, and each case passing the bookings I'm interested in processing, as well as 2 empty objects that aren't used for this booking type. I'm not able to get bookings all into the same datatype, which would make this easier and each booking type needs to be processed differently, so I'm not sure how I can improve this. Any ideas?

    Read the article

  • Refactoring multiple if statements for user authentication with subdomains

    - by go minimal
    I'm building a typical web app where once a user signs up they access the app through their own subdomain (company.myapp.com). The "checking what kind of user if any is logged in" piece is starting to get very hairy and it obviously needs to be well-written because its run so often so I was wondering how you guys would re-factor this stuff. Here are the different states: A user must be logged in, the user must not have a company name, and the sub-domain must be blank A user must be logged in, the user must have a company name, that company name must match the current sub-domain A user must be logged in, the user must have a company name, that company name must match the current sub-domain, and the user's is_admin boolean is true if !session[:user_id].nil? @user = User.find(session[:user_id]) if @user.company.nil? && request.subdomains.first.nil? return "state1" elsif [email protected]? if @user.company.downcase == request.subdomains.first.downcase && [email protected]_admin return "state2" elsif @user.company.downcase == request.subdomains.first.downcase && @user.is_admin return "state3" end end end

    Read the article

  • Refactoring method that was previously injected with implement

    - by ryber
    Greetings, I'm trying to override or extend the Element.show() and .hide() methods in mootools in order to add some WAI-Aria toggling. I was trying to use the Class.Refactor() method like this: Element = Class.refactor(Element, { show: function(displayString) { result = this.previous(displayString); // Do my thing return result; }, hide: function() { result = this.previous(); // Do my thing return result; } }); however, this is not working, previous is null and I think the reason is that Mootools injects those methods through Element.implement. So the methods are not native? I have figured out how to completely replace .show and .hide but I would like to retain all of their existing functionality and just add to it. Any ideas?

    Read the article

  • Refactoring Rails 3 Routes

    - by Martin
    Hello, I have this in my routes: get '/boutique/new' => 'stores#new', :as => :new_store, :constraints => { :id => /[a-z0-9_-]/ } post '/boutique' => 'stores#create', :as => :create_store, :constraints => { :id => /[a-z0-9_-]/ } get '/:shortname' => 'stores#show', :as => :store, :constraints => { :id => /[a-z0-9_-]/ } get '/:shortname/edit' => 'stores#edit', :as => :edit_store, :constraints => { :id => /[a-z0-9_-]/ } put '/:shortname' => 'stores#update', :as => :update_store, :constraints => { :id => /[a-z0-9_-]/ } delete '/:shortname' => 'stores#delete', :as => :destroy_store, :constraints => { :id => /[a-z0-9_-]/ } Is there a cleaner way to do the same? It doesn't look any elegant and even less if I add some more controls/actions to it. Thank you.

    Read the article

  • Javascript code refactoring and assessment

    - by neitony
    I'm using javascript to toggle the display state of some objects based on the time of day. A sample of the code is given below. I was wondering if anyone could give a suggestion as to how I can refactor this code while at the same time improving the logic. switch(tcode) { case 'eur' : eur.setAttribute('style', 'display:block; opacity:0.5'); us.style.display = 'none'; asia.style.display = 'none'; us_inactive.style.display = 'block'; asia_inactive.style.display = 'block'; break; case 'us' : us.style.display = 'block'; eur.style.display = 'none'; asia.style.display = 'none'; eur_inactive.style.display = 'block'; asia_inactive.style.display = 'block'; break; case 'asia' : asia.setAttribute('style', 'display:block; opacity:0.5'); us.style.display = 'none'; eur.style.display = 'none'; eur_inactive.style.display = 'block'; us_inactive.style.display = 'block';

    Read the article

  • Refactoring thick client legacy application

    - by Paul
    I am working on a fat client legacy C++ application which has a lot of business logic mixed in with the presentation side of things. I want to clean things out and refactor the code out completely, so there is a clear seperation of concerns. I am looking at MVC or some other suitable design pattern in order to achieve this. I would like to get recommendations from people who have walked this road before - Do I use MVP or MVC (or another pattern)? What is/are the best practices for undertaking something like this (i.e. useful steps/checks) ?

    Read the article

  • Refactoring and assessment

    - by neitony
    I'm using javascript to toggle the display state of some objects based on the time of day. A sample of the code is given below. I was wondering if anyone could give a suggestion as to how I can refactor this code while at the same time improving the logic. switch(tcode) { case 'eur' : eur.setAttribute('style', 'display:block; opacity:0.5'); us.style.display = 'none'; asia.style.display = 'none'; us_inactive.style.display = 'block'; asia_inactive.style.display = 'block'; break; case 'us' : us.style.display = 'block'; eur.style.display = 'none'; asia.style.display = 'none'; eur_inactive.style.display = 'block'; asia_inactive.style.display = 'block'; break; case 'asia' : asia.setAttribute('style', 'display:block; opacity:0.5'); us.style.display = 'none'; eur.style.display = 'none'; eur_inactive.style.display = 'block'; us_inactive.style.display = 'block';

    Read the article

  • refactoring my code. My headers (Header Guard Issues)

    - by numerical25
    I had a post similar to this awhile ago based on a error I was getting. I was able to fix it but since then I been having trouble doing things because headers keep blocking other headers from using code. Honestly, these headers are confusing me and if anyone has any resources that will address these types of issues, that will be helpful. What I essentially want to do is be able to have rModel.h be included inside RenderEngine.h. every time I add rModel.h to RenderEngine.h, rModel.h is no longer able to use RenderEngine.h. (rModel.h has a #include of RenderEngine.h as well). So in a nutshell, RenderEngine and rModel need to use each others functionalities. On top of all this confusion, the Main.cpp needs to use RenderEngine. stdafx.h #include "targetver.h" #define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers // Windows Header Files: #include <windows.h> // C RunTime Header Files #include <stdlib.h> #include <malloc.h> #include <memory.h> #include <tchar.h> #include "resource.h" main.cpp #include "stdafx.h" #include "RenderEngine.h" #include "rModel.h" // Global Variables: RenderEngine go; rModel *g_pModel; ...code........... rModel.h #ifndef _MODEL_H #define _MODEL_H #include "stdafx.h" #include <vector> #include <string> #include "rTri.h" #include "RenderEngine.h" ........Code RenderEngine.h #pragma once #include "stdafx.h" #include "d3d10.h" #include "d3dx10.h" #include "dinput.h" #include "rModel.h" .......Code......

    Read the article

  • Refactoring one large list of C# properties/fields

    - by dotnetdev
    If you take a look at http://www.c-sharpcorner.com/UploadFile/dhananjaycoder/activedirectoryoperations11132009113015AM/activedirectoryoperations.aspx, there is a huge list of properties for AD in one class. What is a good way to refactor such a large list of (Related) fields? Would making seperate classes be adequate or is there a better way to make this more manageable? Thanks

    Read the article

  • refactoring this function in Java

    - by Joel
    Hi folks, I'm learning Java, and I know one of the big complaints about newbie programmers is that we make really long and involved methods that should be broken into several. Well here is one I wrote and is a perfect example. :-D. public void buildBall(){ /* sets the x and y value for the center of the canvas */ double i = ((getWidth() / 2)); double j = ((getHeight() / 2)); /* randomizes the start speed of the ball */ vy = 3.0; vx = rgen.nextDouble(1.0, 3.0); if (rgen.nextBoolean(.05)) vx = -vx; /* creates the ball */ GOval ball = new GOval(i,j,(2 *BALL_RADIUS),(2 * BALL_RADIUS)); ball.setFilled(true); ball.setFillColor(Color.RED); add(ball); /* animates the ball */ while(true){ i = (i + (vx* 2)); j = (j + (vy* 2)); if (i > APPLICATION_WIDTH-(2 * BALL_RADIUS)){ vx = -vx; } if (j > APPLICATION_HEIGHT-(2 * BALL_RADIUS)){ vy = -vy; } if (i < 0){ vx = -vx; } if (j < 0){ vy = -vy; } ball.move(vx + vx, vy + vy); pause(10); /* checks the edges of the ball to see if it hits an object */ colider = getElementAt(i, j); if (colider == null){ colider = getElementAt(i + (2*BALL_RADIUS), j); } if (colider == null){ colider = getElementAt(i + (2*BALL_RADIUS), j + (2*BALL_RADIUS)); } if (colider == null){ colider = getElementAt(i, j + (2*BALL_RADIUS)); } /* If the ball hits an object it reverses direction */ if (colider != null){ vy = -vy; /* removes bricks when hit but not the paddle */ if (j < (getHeight() -(PADDLE_Y_OFFSET + PADDLE_HEIGHT))){ remove(colider); } } } You can see from the title of the method that I started with good intentions of "building the ball". There are a few issues I ran up against: The problem is that then I needed to move the ball, so I created that while loop. I don't see any other way to do that other than just keep it "true", so that means any other code I create below this loop won't happen. I didn't make the while loop a different function because I was using those variables i and j. So I don't see how I can refactor beyond this loop. So my main question is: How would I pass the values of i and j to a new method: "animateBall" and how would I use ball.move(vx + vx, vy + vy); in that new method if ball has been declared in the buildBall method? I understand this is probably a simple thing of better understanding variable scope and passing arguments, but I'm not quite there yet...

    Read the article

  • Refactoring nested foreach statement

    - by dotnetdev
    Hi, I have a method with a nested foreach collection (iterate a set of objects and then look inside each object). I saw in a book a good pattern to make this much more elegant but cannot remember/find the code example. How else could I make this more tidy? The code is just a typical nested foreach statement so I have not provided a code sample. Thanks

    Read the article

  • Testing local scoped object with mockito without refactoring

    - by supertonsky
    Say I have the following code: public class ClassToTest { AnotherClass anotherClass; public void methodToTest( int x, int y ) { int z = x + y anotherClass.receiveSomething( z ); } } public class AnotherClass { public void receiveSomething( int z ) {.. do something.. } } I want to make assertion on the value of the variable z. How do I do this? Variables x, y, and z could be some other Java class types, and I just used "int" for simplicity.

    Read the article

  • Refactoring a nested loop

    - by user3517441
    I have the following code which I use a lot of times in the class. for (int i = 0; i < someList.size(); i++) { for (int j = 0; j < someList.size(); j++) { if (i != j) { someList.get(i).sendMessageTo(someList.get(j))); //variable action } } } The purpose of the loop is to make each element in the List to send a message (or perform another action) to every element in the list except itself. Is there any way I can create a helper method so I don't have to repeat the loop code. I want to be able to state the variable action and call the helper method. Thanks.

    Read the article

  • Refactoring FAT client legacy application

    - by Paul
    I am working on a fat client legacy C++ application which has a lot of business logic mixed in with the presentation side of things. I want to clean things out and refactor the code out completely, so there is a clear seperation of concerns. I am looking at MVC or some other suitable design pattern in order to achieve this. I would like to get recommendations from people who have walked this road before - Do I use MVP or MVC (or another pattern)? What is/are the best practices for undertaking something like this (i.e. useful steps/checks) ?

    Read the article

  • PhpMyAdmin import/export - strange character encoding issues.

    - by John Hunt
    Hello, I'm migrating a site to a new host, and there are a couple of databases on there. There's no SSH access so I'm stuck with phpmyadmin. The issue is that certain characters (namely just whitespace) seems to being corrupt on the new site (same html, and apache doesn't seem to be messing with any encodings - you can see the strange characters have changed when I use less on my linux machine after downloading a table dump from both servers.) The issue isn't as bad if I import into the new database as utf-8 - whitespace characters only have one funny A type symbol instead of two. I've been trying various combinations of character encoding etc to no avail. Exporting from: phpMyAdmin 2.6.2 MySQL 4.1.20 MySQL connection collation: utf8_general_ci MySQL charset: UTF-8 Unicode (utf8) Collation on tables and their fields is: latin1_swedish_ci Importing to: phpMyAdmin - 2.11.9.2 MySQL client version: 5.0.45 MySQL charset: UTF-8 Unicode (utf8) MySQL connection collation: utf8_general_ci The import sql has this kind of thing in it: ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=192 ; I get the impression this is actually a bug or something with mysqldump as nothing seems to work.. does anyone have any insight into this? Cheers, John.

    Read the article

  • Using LINQ to SQL with multiple databases

    - by Stuart Ferguson
    I am working on a new project and hoping to use LINQ to SQL for the data access but have come across the following issue. I need to have my application access 3 databases with similar but not the same table structure, for example Database1 and Database 2 has a table called tblCustomer with 2 columns CustomerKey and CustomerName Database2 has a table called tblCustomer with 3 columns CustomerKey, CustomerName and CustomerPostCode I am looking for a solution that will allow me a query all three databases without the need for 3 GetCustomerList functions as Database1 and Database2 could use the same function as are the same structure, with an override function for database 3 to bring back the additional field. Is there a way i can declare a base datacontext class to handle Database 1 and 2 with an inherited version for Database 3. Thanks In Advance Stuart Ferguson

    Read the article

  • hundreds of databases sql server log shipping

    - by Oliver
    SQL Server 2005 Standard 64x, with 300+ tiny databases currently (5MB each), user base adds databases as needed. Want to implement log shipping for warm standby, but not via the wizard, since that looks like it adds 3 jobs (1 on primary, 2 on secondary) for each log-shipped database. Do I try to write my own or use something like Quest's LiteSpeed? Or am I being too squeamish about having hundreds of SQL Server Agent jobs and all of them firing off (or worse, would I have to try to time them)? All advice welcome.

    Read the article

  • Grails multiple databases

    - by srinath
    Hi, how can we write queries on 2 databases . I installed datasources plugin and domain classes are : class Organization { long id long company_id String name static mapping = { version false table 'organization_' id column : 'organizationId' company_id column : 'companyId' name column : 'name' } } class Assoc { Integer id Integer association_id Integer organization_id static mapping = { version false table 'assoc' id column : 'ASSOC_ID' association_id column : 'ASSOCIATION_ID' organization_id column : 'ORGANIZATION_ID' } } this is working : def org = Organization.list() def assoc = Assoc.list() and this is not working : def query = Organization.executeQuery("SELECT o.name as name, o.id FROM Organization o WHERE o.id IN (SELECT a.organization_id FROM Assoc a )") error : org.hibernate.hql.ast.QuerySyntaxException: Assoc is not mapped [SELECT o.name as name, o.id FROM org.com.domain.Organization o WHERE o.id IN (SELECT a.organization_id FROM AssocOrg a )] How can we connect with 2 databases using single query ? thanks in advance .

    Read the article

  • Consolidate data from many different databases into one with minimum latency

    - by NTDLS
    I have 12 databases totaling roughly 1.0TB, each on a different physical server running SQL 2005 Enterprise - all with the same exact schema. I need to offload this data into a separate single database so that we can use for other purposes (reporting, web services, ect) with a maximum of 1 hour latency. It should also be noted that these servers are all in the same rack, connected by gigabit connections and that the inserts to the databases are minimal (Avg. 2500 records/hour). The current method is very flakey: The data is currently being replicated (SQL Server Transactional Replication) from each of the 12 servers to a database on another server (yes, 12 different employee tables from 12 different servers into a single employee table on a different server). Every table has a primary key and the rows are unique across all tables (there is a FacilityID in each table). What are my options, these has to be a simple way to do this.

    Read the article

  • Attach and upgrade TFS 2005 databases to a TFS 2008 installation

    - by henriksen
    I have a Windows server 2008 with SQL 2008 and TFS 2008 installed. And I have another box with SQL 2005 and TFS 2005 installed. Does anyone know of a way I can just transfer the databases (or data in another way) from TFS 2005 to TFS 2008. Any data on the 2008 box can be deleted. The machines are not in a domain so all accounts are local. So I'll have to fix that afterwards, but that's managable. Basically, can I attach the databases and run an upgrade command?

    Read the article

  • Refactor/rewrite code or continue?

    - by Dan
    I just completed a complex piece of code. It works to spec, it meets performance requirements etc etc but I feel a bit anxious about it and am considering rewriting and/or refactoring it. Should I do this (spending time that could otherwise be spent on features that users will actually notice)? The reasons I feel anxious about the code are: The class hierarchy is complex and not obvious Some classes don't have a well defined purpose (they do a number of unrelated things) Some classes use others internals (they're declared as friend classes) to bypass the layers of abstraction for performance, but I feel they break encapsulation by doing this Some classes leak implementation details (eg, I changed a map to a hash map earlier and found myself having to modify code in other source files to make the change work) My memory management/pooling system is kinda clunky and less-than transparent They look like excellent reasons to refactor and clean code, aiding future maintenance and extension, but could be quite time consuming. Also, I'll never be perfectly happy with any code I write anyway... So, what does stackoverflow think? Clean code or work on features?

    Read the article

  • Alternative databases to use when putting IIS Logs into a database using LogParser

    - by Robin Day
    We have run some scripts that use LogParser to dump our IIS logs into a SQL Server database. We can then query this to get simple stats on hits, usage etc. It's also good when linking it to error log databases and performance counter database to compare usage with errors, etc. Having implemented this for just one system and for the last 2-3 weeks we already have a 5GB database with around 10 million records. This is making any queries to this database quite slow and will no doubt cause storage issues if we continue to log as we are. Can anyone suggest any alternative databases that we could use for this data that would be more efficient for such logs? I'd be particularly interested in any experience of Google's BigTable or Amazon's SimbleDB. Are either of these suitable for reporting queries? COUNTs, GROUP BYs, PIVOTs?

    Read the article

  • Simple way to reorder methods of a Java class in IntelliJ?

    - by Péter Török
    Is there a simpler way of reordering methods within a class source file in IntelliJ than cutting and pasting the code manually? Nowadays I often need this while refactoring legacy code, e.g. to move related methods close to each other in the source code. In Eclipse AFAIK there is a view similar to the Structure view of IntelliJ, where I can drag and drop methods around. However, this does not work in IntelliJ and I couldn't find any hints from its help either. I am using IntelliJ 9.0.2 to be specific.

    Read the article

  • Inconsistent MySQL COLLATE errors across databases

    - by Teflon Ted
    I have two physically-separate MySQL databases on which I have to run a single query. The query has a section of SQL that looks like this: and foo_table.bar_column like concat('%', rules.pattern, '%') COLLATE utf8_general_ci It runs fine on database A but on database B I get this error: ERROR 1253 (42000): COLLATION 'utf8_general_ci' is not valid for CHARACTER SET 'latin1' If I remove the collation it runs fine on database B but on database A I get this error: ERROR 1267 (HY000): Illegal mix of collations (utf8_general_ci,IMPLICIT) and (utf8_unicode_ci,IMPLICIT) for operation 'like' Is there a version of the query that will run on both databases? Or, is there a configuration I can change on either database to make the query happy in both places? Update: Database A is version 5.1.38, Database B is version 5.1.34

    Read the article

< Previous Page | 16 17 18 19 20 21 22 23 24 25 26 27  | Next Page >