Search Results

Search found 1010 results on 41 pages for 'reuse'.

Page 7/41 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • When using method chaining, do I reuse the object or create one?

    - by MainMa
    When using method chaining like: var car = new Car().OfBrand(Brand.Ford).OfModel(12345).PaintedIn(Color.Silver).Create(); there may be two approaches: Reuse the same object, like this: public Car PaintedIn(Color color) { this.Color = color; return this; } Create a new object of type Car at every step, like this: public Car PaintedIn(Color color) { var car = new Car(this); // Clone the current object. car.Color = color; // Assign the values to the clone, not the original object. return car; } Is the first one wrong or it's rather a personal choice of the developer? I believe that he first approach may quickly cause the intuitive/misleading code. Example: // Create a car with neither color, nor model. var mercedes = new Car().OfBrand(Brand.MercedesBenz).PaintedIn(NeutralColor); // Create several cars based on the neutral car. var yellowCar = mercedes.PaintedIn(Color.Yellow).Create(); var specificModel = mercedes.OfModel(99).Create(); // Would `specificModel` car be yellow or of neutral color? How would you guess that if // `yellowCar` were in a separate method called somewhere else in code? Any thoughts?

    Read the article

  • Can I reuse my nameservers from one domain registrar with another?

    - by Nikki Erwin Ramirez
    My regular domain is one I got from GoDaddy. Just recently, I registered a short .cr domain (Costa Rica) in http://www.nic.cr/ . During registration, they asked for nameservers (and just nameservers), so I thought of reusing my GoDaddy nameservers. I kinda thought it would just be a straight-forward mapping, but nothing's happening, though. What am I missing here? (There is an option to use their own nameservers, but I just wanted to explore this option. If there's nothing to be had here, I'll fall back to using theirs.)

    Read the article

  • How do game programmers design their classes to reuse in AI, network and play and pass mode?

    - by Amogh Talpallikar
    For a two player game where, your opponent could be on the network, CPU itself or near you where you would play turn by turn on the same machine. How do people design classes for re-use ? I am in a similar situation and have no experience in making such complex games. But here is what I have thought, If I am a player object , I should only be interacting with the GameManager or GameEngine Singleton , from which I will get various notifications about the game status. I dont care where and who my opponent is, this GameManager depending upon the game mode, will interact with gameNetworkManager , or AI tell me what the opponent played. I am not sure about the scenario where we play and pass [turn by turn on same machine]. Hoping for a brief but clear explanation or at least a link to a similar resource.:)

    Read the article

  • Legally, can I re reuse code for different customers?

    - by canice
    The company I work for develops custom factory automation applications for multiple customers. Even though each application is custom, they contain common code which is re-used across projects. One of the customers is now looking for the source code to their application, which has caused a major storm in the company. Management have decided that we can't give them the source to the shared components as they are used by other customers. I've been asked to modify the shared components 'enough' so as they aren't common. So my questions are: 1) Legally, should there be any problem with re-using common components for different customer? 2) If I really need to modify the common components, then how much is 'enough' ? (I know this sucks, but I either do this or hand in my notice). Oh yeah, and my company has no license in place with any of these customers.

    Read the article

  • Problems with SQL Server 2008 - "The client was unable to reuse a session with SPID 62, which had ..

    - by GrZeCh
    Hello, I'm having problems with my SQL Server 2008 installation (10.0.2531.0 - SP1 installed). It works as a database server for small hosting environment (about 500 sites). I'm getting errors like this: The client was unable to reuse a session with SPID 62, which had been reset for connection pooling. The failure ID is 29. This error may have been caused by an earlier operation failing. Check the error logs for failed operations immediately before this error message. in Windows event log and when I run this: SELECT * FROM sys.dm_os_performance_counters WHERE object_name = 'SQLServer:General Statistics' I see that one of counters looks a little odd: Logins/sec 429 Connection Reset/sec 163459 Logouts/sec 399 User Connections 30 Logical Connections 33 any ideas how to check what is causing this problem?

    Read the article

  • How to reuse backup on Time Machine on Snow Leopard after a logic board change, after choosing wrong

    - by kmiffy
    After my logic board was replaced, I connected my laptop back to my network, and Time Machine gave me a popup, as shown on this thread: http://superuser.com/questions/78068/recycle-time-machine-for-new-machine/78264#78264 I misread the question and clicked on "Create New Backup" when I should have clicked on "Reuse Backup" to connect to my old backup file. How can I trigger that popup again? Turning Time Machine on and off does not work, and the instructions on forums to fix via terminal doesn't work because snow leopard is missing the fsaclctl command (and I'm also not familiar with terminal commands.) Thanks.

    Read the article

  • Reuse remote ssh connections and reduce command/session logging verbosity?

    - by ewwhite
    I have a number of systems that rely on application-level mirroring to a secondary server. The secondary server pulls data by means of a series of remote SSH commands executed on the primary. The application is a bit of a black box, and I may not be able to make modifications to the scripts that are used. My issue is that the logging in /var/log/secure is absolutely flooded with requests from the service user, admin. These commands occur many times per second and have a corresponding impact on logs. They rely on passphrase-less key exchange. The OS involved is EL5 and EL6. Example below. Is there any way to reduce the amount of logging from these actions. (By user? By source?) Is there a cleaner way for the developers to perform these ssh executions without spawning so many sessions? Seems inefficient. Can I reuse the existing connections? Example log output: Jul 24 19:08:54 Cantaloupe sshd[46367]: pam_unix(sshd:session): session closed for user admin Jul 24 19:08:54 Cantaloupe sshd[46446]: Accepted publickey for admin from 172.30.27.32 port 33526 ssh2 Jul 24 19:08:54 Cantaloupe sshd[46446]: pam_unix(sshd:session): session opened for user admin by (uid=0) Jul 24 19:08:54 Cantaloupe sshd[46446]: pam_unix(sshd:session): session closed for user admin Jul 24 19:08:54 Cantaloupe sshd[46475]: Accepted publickey for admin from 172.30.27.32 port 33527 ssh2 Jul 24 19:08:54 Cantaloupe sshd[46475]: pam_unix(sshd:session): session opened for user admin by (uid=0) Jul 24 19:08:54 Cantaloupe sshd[46475]: pam_unix(sshd:session): session closed for user admin Jul 24 19:08:54 Cantaloupe sshd[46504]: Accepted publickey for admin from 172.30.27.32 port 33528 ssh2 Jul 24 19:08:54 Cantaloupe sshd[46504]: pam_unix(sshd:session): session opened for user admin by (uid=0) Jul 24 19:08:54 Cantaloupe sshd[46504]: pam_unix(sshd:session): session closed for user admin Jul 24 19:08:54 Cantaloupe sshd[46583]: Accepted publickey for admin from 172.30.27.32 port 33529 ssh2 Jul 24 19:08:54 Cantaloupe sshd[46583]: pam_unix(sshd:session): session opened for user admin by (uid=0) Jul 24 19:08:54 Cantaloupe sshd[46583]: pam_unix(sshd:session): session closed for user admin Jul 24 19:08:54 Cantaloupe sshd[46612]: Accepted publickey for admin from 172.30.27.32 port 33530 ssh2 Jul 24 19:08:54 Cantaloupe sshd[46612]: pam_unix(sshd:session): session opened for user admin by (uid=0) Jul 24 19:08:54 Cantaloupe sshd[46612]: pam_unix(sshd:session): session closed for user admin Jul 24 19:08:55 Cantaloupe sshd[46641]: Accepted publickey for admin from 172.30.27.32 port 33531 ssh2 Jul 24 19:08:55 Cantaloupe sshd[46641]: pam_unix(sshd:session): session opened for user admin by (uid=0) Jul 24 19:08:55 Cantaloupe sshd[46641]: pam_unix(sshd:session): session closed for user admin Jul 24 19:08:55 Cantaloupe sshd[46720]: Accepted publickey for admin from 172.30.27.32 port 33532 ssh2 Jul 24 19:08:55 Cantaloupe sshd[46720]: pam_unix(sshd:session): session opened for user admin by (uid=0) Jul 24 19:08:55 Cantaloupe sshd[46720]: pam_unix(sshd:session): session closed for user admin Jul 24 19:08:55 Cantaloupe sshd[46749]: Accepted publickey for admin from 172.30.27.32 port 33533 ssh2 Jul 24 19:08:55 Cantaloupe sshd[46749]: pam_unix(sshd:session): session opened for user admin by (uid=0) Jul 24 19:08:55 Cantaloupe sshd[46749]: pam_unix(sshd:session): session closed for user admin Jul 24 19:08:55 Cantaloupe sshd[46778]: Accepted publickey for admin from 172.30.27.32 port 33534 ssh2 Jul 24 19:08:55 Cantaloupe sshd[46778]: pam_unix(sshd:session): session opened for user admin by (uid=0) Jul 24 19:08:55 Cantaloupe sshd[46778]: pam_unix(sshd:session): session closed for user admin Jul 24 19:08:55 Cantaloupe sshd[46857]: Accepted publickey for admin from 172.30.27.32 port 33535 ssh2

    Read the article

  • How to declare class attributes in swift, just like UITableViewCell reuse identifiers?

    - by martin
    I am trying to declare a reuse identifier associated to a UITableView subclass in swift. From my understanding I would like to declare an class stored property (not an instance one) so i have access via: MyCustomTableCell.ReuseIdentifer. Here is what I was trying: class MyCustomTableViewCell : UITableViewCell { class let ReuseIdentifier = "MyCustomTableViewCellReuseIdentifier" } The compiler mentions that class attributes are not supported yet. How to declare such kind of constants associated to a class type in a clean way?

    Read the article

  • How can i reuse a color in a stylesheet?

    - by Michel
    Hi, i have a stylesheet and a lot of styles with the same border color (#CCCCCC to be precise). Is there a way to specify some kind of variable and reuse that, so in stead of typing #CCCCCC over and over, i can type border: 1px solid $bordercolor; ps i'm using asp.net mvc

    Read the article

  • Explicit return from a Ruby method - implementation hiding, reuse and optimisations.

    - by Chris McCauley
    Hi, Rather than allowing a Ruby method to blindly return the last statement evaluated, is there any advantage to returning nil explicitly? In terms of implementation hiding and reuse, it seems dangerous to blindly allow the last expression evaluated to be returned - isn't there a danger that a user will rely on this only to get a nasty surprise when the implementation is modified? Surely returning nil would be better unless an explicit return value was given. Following on, is there an optimisation that Ruby can make when the return is a simple type rather than a reference to a more complex object? Chris

    Read the article

  • Explicit return form a Ruby method - implementation hiding, reuse and optimisations.

    - by Chris McCauley
    Hi, Rather than allowing a Ruby method to blindly return the last statement evaluated, is there any advantage to returning nil explicitly? In terms of implementation hiding and reuse, it seems dangerous to blindly allow the last expression evaluated to be returned - isn't there a danger that a user will rely on this only to get a nasty surprise when the implementation is modified? Surely returning nil would be better unless an explicit return value was given. Following on, is there an optimisation that Ruby can make when the return is a simple type rather than a reference to a more complex object? Chris

    Read the article

  • How to reuse a dropdownlist each row of a table instead of rebuilding it.

    - by Praesagus
    I have a table the uses the same dropdown list in each row. I thought that I could just create one dropdown list and then reuse it in each new row, but the table only ends up with one row unless I create "new" dropdownlist. Am I approaching this all wrong? Thanks private void UserRoles() { Table table = MakeTable(); Ewo.sqlDataStore.Administrator sql = new Ewo.sqlDataStore.Administrator(); DataSet dataset =sql.SiteUserRoleList(); DropDownList sel = RoleList(dataset.Tables[0]); if(tools.validDataSet(dataset)) { if (dataset.Tables.Count > 1)//existing roles are #2, show the roles the user is part of { foreach (DataRow dRow in dataset.Tables[1].Rows) { table.Rows.Add(CreateRoleRow(Convert.ToString(dRow["SitePageGroupName"]), sel));//add a row with data } } table.Rows.Add(CreateRoleRow(sel));//add a blank row on the bottom } AdminSiteUerRoles.Controls.Add(table);//add it all to the page }

    Read the article

  • How can I reuse .NET resources in multiple executables?

    - by Brandon
    I have an existing application that I'm supposed to take and create a "mini" version of. Both are localized apps and we would like to reuse the resources in the main application as is. So, here's the basic structure of my apps: MainApplication.csproj /Properties/Resources.resx /MainUserControl.xaml (uses strings in Properties/Resources.resx) /MainUserControl.xaml.cs MiniApplication.csproj link to MainApplication/Properties/Resources.resx link to MainApplication/MainUserControl.xaml link to MainApplication/MainUserControl.xaml.cs MiniApplication.xaml (tries to use MainUserControl from MainApplication link) So, in summary, I've added the needed resources and user control from the main application as links in the mini application. However, when I run the mini application, I get the following exception. I'm guessing it's having trouble with the different namespaces, but how do I fix? Could not find any resources appropriate for the specified culture or the neutral culture. Make sure \"MainApplication.Properties.Resources.resources\" was correctly embedded or linked into assembly \"MiniApplication\" at compile time, or that all the satellite assemblies required are loadable and fully signed. FYI, I know I could put the user control in a user control library but the problem is that the mini application needs to have a small footprint. So, we only want to include what we need.

    Read the article

  • How to recycle/reuse/continue Time Machine for a new Mac?

    - by bmargulies
    I have been backing up a MacBook Pro to an external hard disk with Time Machine. I got a new laptop, used the firewire connector to pull the universe across to it, and started it up. It does not want to just pick up where I left off with the backups; it wants to start a new backup sequence and thus I need a ton of additional disk space. Does anyone know a way to force it to just incrementally back up to the existing backup set?

    Read the article

  • Looking for suggestions on how to reuse AlertDialogs to confirm actions of contextual menus on the items of an ActivityList

    - by Ozone
    I use a ListActivity to display a list of items. The user can long-press an item in the list to display a contextual menu. This menu contains among other things an option to delete the long-pressed item. When the user selects this option, a dialog pops up asking for confirmation of the deletion. Upon confirmation, the item is deleted from the list. I would like to reuse the AlertDialog as much as possible. My attempts at using onPrepareDialog(int, View, Bundle) have been defeated by the fact that the Bundle is not passed to the DialogInterface.OnClickListener. I end up having to recreate a listener on every invocation. I see several ways to solve this: recreate the dialog on every occasion (pros: simple, cons: wasteful) keep the DialogInterface.OnClickListener in a field on the ListActivity and keep the item to be deleted as a field of the listener. (pros: no memory waste, cons: need to manage state). Q: is this safe? have onPrepareDialog update the title, and bind new View.OnClickListeners on the buttons of the AlertDialog. (pros: limit waste, cons: new View.OnClickListener on every invocation). If DialogInterface.OnClickListener accepted a Bundle, I wouldn't have to jump through hoops to keep track of the item being deleted. This is not a blocker, but I would love to see an elegant solution. I would love to hear your suggestions :) Here is the code for option #1, if you want to play with this: public class Example extends ListActivity { private static final int CONFIRM_DELETE_DIALOG = 1; private static final String POSITION_KEY = "position"; private ArrayAdapter<String> mAdapter; @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); mAdapter = new ArrayAdapter<String>( this, android.R.layout.simple_list_item_1, new String[] { "one", "two" }); setListAdapter(mAdapter); registerForContextMenu(getListView()); } @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); getMenuInflater().inflate(R.menu.my_lovely_menu, menu); } @Override public boolean onContextItemSelected(MenuItem item) { AdapterContextMenuInfo info = (AdapterContextMenuInfo) item.getMenuInfo(); switch (item.getItemId()) { case R.id.delete_item: Bundle bundle = new Bundle(); bundle.putInt(POSITION_KEY, info.position); showDialog(CONFIRM_DELETE_DIALOG, bundle); return true; default: return super.onContextItemSelected(item); } } @Override protected Dialog onCreateDialog(int id, Bundle args) { switch (id) { case CONFIRM_DELETE_DIALOG: final int position = args.getInt(POSITION_KEY); AlertDialog.Builder builder = new AlertDialog.Builder(); builder.setCancelable(false); builder.setTitle(String.format( getString(R.string.confirm_delete), mAdapter.getItem(position))); DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { switch (which) { case DialogInterface.BUTTON_POSITIVE: mAdapter.remove(mAdapter.getItem(position)); // Dismiss the dialog to ensure OnDismissListeners are notified. dialog.dismiss(); break; case DialogInterface.BUTTON_NEGATIVE: // Cancel the dialog to ensure OnCancelListeners are notified. dialog.cancel(); break; } // Remove the dialog so it is re-created next time it is required. removeDialog(CONFIRM_DELETE_DIALOG); } }; builder.setPositiveButton(android.R.string.yes, listener); builder.setNegativeButton(android.R.string.no, listener); return builder.create(); default: return super.onCreateDialog(id, args); } } }

    Read the article

  • Creating and Using a jQuery Plug-in in ASP.NET Web Forms

    - by bipinjoshi
    Developers often resort to code reuse techniques in their projects. As far as ASP.NET framework server side programming is concerned classes, class libraries, components, custom server controls and user controls are popular code reuse techniques. Modern ASP.NET web applications no longer restrict themselves only to server side programming. They also make use of client side scripting to render rich web forms. No wonder that Microsoft Visual Studio 2010 includes jQuery library by default as a part of newly created web site. If you are using jQuery for client side scripting then one way to reuse your client side code is to create a jQuery plug-in. Creating a plug-in allows you to bundle your reusable jQuery code in a neat way and then reuse it across web forms. In this article you will learn how to create a simple jQuery plug-in from scratch. You will also learn about certain guidelines that help you build professional jQuery plug-ins.http://www.bipinjoshi.net/articles/aae84a03-b4a8-477d-b087-5b7f42935220.aspx 

    Read the article

  • In C# should I reuse a function / property parameter to compute temp result or create a temporary v

    - by Hamish Grubijan
    The example below may not be problematic as is, but it should be enough to illustrate a point. Imagine that there is a lot more work than trimming going on. public string Thingy { set { // I guess we can throw a null reference exception here on null. value = value.Trim(); // Well, imagine that there is so much processing to do this.thingy = value; // That this.thingy = value.Trim() would not fit on one line ... So, if the assignment has to take two lines, then I either have to abusereuse the parameter, or create a temporary variable. I am not a big fan of temporary variables. On the other hand, I am not a fan of convoluted code. I did not include an example where a function is involved, but I am sure you can imagine it. One concern I have is if a function accepted a string and the parameter was "abused", and then someone changed the signature to ref in both places - this ought to mess things up, but ... who would knowingly make such a change if it already worked without a ref? Seems like it is their responsibility in this case. If I mess with the value of value, am I doing something non-trivial under the hood? If you think that both approaches are acceptable, then which do you prefer and why? Thanks.

    Read the article

  • Good-practices: How to reuse .csproj and .sln files to create your MSBuild script for CI ?

    - by Gishu
    What is the painless/maintainable way of using MSBuild as your build runner ? (Forgive the length of this post) I was just trying my hand at TeamCity (which I must say is awesome w.r.t. learning curve and out of the box functionality). I got an SVN MSBuild NUnit NCover combo working. I was curious as to how moderate to large projects are using MSBuild - I've just pointed MSBuild to my Main sln file. I've spent some time with NAnt some years ago and I found MSBuild to be a bit obtuse. The docs are too dense/detailed for a beginner. MSBuild seems to have some special magic to handle .sln files ; I tried my hand at writing a custom build script by hand, linking/including .csproj files in order (such that I could have custom pre-post build tasks). However it threw up (citing duplicate target imports). I'm assuming most devs wouldn't want to go messing around with msbuild proj files - they'd be making changes to the .csproj and .sln files. Is there some tool / MSBuild task that reverse-engineers a new script from an existing .sln + its .csproj files that I'm unaware of ? If I'm using MSBuild just to do the compile step, I might as well use Nant with an exec task to MSBuild for compiling the solution ? I've this nagging feeling that I'm missing something obvious. My end-goal here is to have a MSBuild build script which builds the solution that acts as a build script instead of a compile step. Allows custom pre/post tasks. (e.g. call nunit to run a nunit project (which seems to be not yet supported via the teamcity web UI)) stays out of the way of the developers making changes to the solution. No redundancy ; shouldn't require devs to make the same change in 2 places

    Read the article

  • how to reuse the area in a container when any component is removed from it?

    - by vybhav
    hi! i hav a panel and i m trying to remove labels from it which were added to it during run-time. but when labels are removed succesfully i m not able to use the space,left by that label,again to add any label to it. thanks in anticipation of the solution. here is the relevant code snippet: to add label to the panel: JLabel jl = new JLabel(); jl.setOpaque(true); jl.setIcon(new ImageIcon("D:/Project/router2.jpg")); jl.setBounds(x, y,jl.getPreferredSize().width,jl.getPreferredSize().height); for(Component c :lcomponent) { flag=true; Rectangle r4=c.getBounds(); int x1=(int) r4.getX(); int y1=(int) r4.getY(); Rectangle r5 = new Rectangle(new Point(x1-60, y1-60),new Dimension(170,170)); if(r5.contains(p)){ //To ensure that two labels do not overlap or are too close flag = false; // to each other break; }} if(flag) { p2.add(jl); //p2 is a panel Component c2 = p2.getComponentAt(x,y); p2.repaint(); lcomponent.add(c2); //lcomponent is an ArrayList<Component> to store all the labels added to the panel } 2.to remove the label: p2.remove(); p2.repaint();

    Read the article

  • Vimrc: how to reuse code and definitions for differnt file types?

    - by sixtyfootersdude
    I have defined my own file types using vim. For example I have: .classNotes .reportJotNotes .homework These file types are defined in .vim files: ~/.vim/syntax/homework.vim ~/.vim/syntax/reportJotNotes.vim ~/.vim/syntax/homework.vim Many of these things have several of the same code in them. Ie they all have this for titles: syn region JakeTitle start=+=== + end=+===+ oneline highlight JakeTitle ctermbg=black ctermfg=Yellow syn region JakeMasterTitle start=+==== + end=+====+ oneline highlight JakeMasterTitle cterm=bold term=bold ctermbg=black ctermfg=LightBlue Instead of having this in all three .vim files I would rather have it in one file and then in each file could source it. How can I do this?

    Read the article

  • With Protobuf-net, does it allow deserialization reuse existing instances if they are the same?

    - by Stecy
    I'm using Protobuf-net. Suppose I have a list of Gizmo objects serialized and that each gizmo object reference a Gazoo object. The Gazoo object might be the same object referred by several Gizmo objects. How would deserialization work in this situation? Would I get more than one copies of Gazoos for the same referred one in the gizmo objects? What I would expect would be one copy of Gazoo for all the duplicates in the serialized data.

    Read the article

  • Can you reuse a mysql result set in PHP?

    - by MarathonStudios
    I have a result set I pull from a large database: $result = mysql_query($sql); I loop through this recordset once to pull specific bits of data and get averages using while($row = mysql_fetch_array($result)). Later in the page, I want to loop through this same recordset again and output everything - but because I used the recordset earlier, my second loop returns nothing. I finally hacked around this by looping through a second identical recordset ($result2 = mysql_query($sql);), but I hate to make the same SQL call twice. Any way I can loop through the same dataset multiple times?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >