Search Results

Search found 15316 results on 613 pages for 'coding style'.

Page 5/613 | < Previous Page | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • How Can I up my Street Cred in the coding world

    - by RedEye
    I know this isn't directly related to a specific coding problem. It's a more general programming question. I'm a n00b... Been coding for 1 year, and it's where I belong. I want to get hardcore and put everything I have into it. I started with C++ and now I'm into C#. I love it all. What can I do to up my game and up my respect in the programming world?

    Read the article

  • DataGrid: How to style or disable the default ContextMenu of a Cell

    - by Nike
    I use DataGrid with DataGridTextColumns. How can I style or disable the default ContextMenu of a Cell? I tried to add a style for DataGridCell: <DataGrid.CellStyle> <Style TargetType="{x:Type DataGridCell}"> <Setter Property="ContextMenu" Value="{x:Null}"/> </Style> </DataGrid.CellStyle> but it doesn't work. As I understand, it is a TextBox inside a Cell when the Cell in edit mode. I tried also to add a style for TextBox, but it have an effect only on TextBoxes in XAML, but not on the DataGrid cells.

    Read the article

  • WPF style problem with custom control and textbox-derived class

    - by Martin
    I had the following situation: main application has app.xaml, which sets the style for TextBox controls a custom control is implemented in a separate DLL, and uses several TextBox controls The main application's TextBox style is applied to the custom control's TextBox controls. Cool! My problem comes in because I need to use a class derived from TextBox in the custom control. Now the main app's TextBox style is no longer applied. Can the custom control DLL have something like "app.xaml" where I can set the style for all my derived TextBox controls? Or can the main application somehow set the style for all TextBox-derived classes? Thanks!

    Read the article

  • Style question: Writing "this." before instance variable and methods: good or bad idea?

    - by Uri
    One of my nasty (?) programming habits in C++ and Java is to always precede calls or accesses to members with a this. For example: this.process(this.event). A few of my students commented on this, and I'm wondering if I am teaching bad habits. My rationale is: 1) Makes code more readable — Easier to distinguish fields from local variables. 2) Makes it easier to distinguish standard calls from static calls (especially in Java) 3) Makes me remember that this call (unless the target is final) could end up on a different target, for example in an overriding version in a subclass. Obviously, this has zero impact on the compiled program, it's just readability. So am I making it more or less readable? Related Question Note: I turned it into a CW since there really isn't a correct answer.

    Read the article

  • Most frustrating programming style you've encountered

    - by JaredPar
    When it comes to coding style I'm a pretty relaxed programmer. I'm not firmly dug into a particular coding style. I'd prefer a consistent overall style in a large code base but I'm not going to sweat every little detail of how the code is formatted. Still there are some coding styles that drive me crazy. No matter what I can't look at examples of these styles without reaching for a VIM buffer to "fix" the "problem". I can't help it. It's not even wrong, I just can't look at it for some reason. For instance the following comment style almost completely prevents me from actually being able to read the code. if (someConditional) // Comment goes here { other code } What's the most frustrating style you've encountered?

    Read the article

  • Why cant i add Orientation property to the style setter in WPF

    - by nihi_l_ist
    When i write something like this: <Style x:Key="panelS"> <Setter Property="Orientation" Value="Horizontal" /> <Setter Property="DockPanel.Dock" Value="Top" /> </Style> I get the error that says: Cannot resolve the Style Property 'Orientation'. Verify that the owning type is the Style's TargetType, or use Class.Property syntax to specify the Property. Sure i have a Dock panel with many Stackpanels in it so i want to move Stackpanel's properties to the style. But there is this error and i dont quite understand what it means and what is the workaround(..i'd wanted not to assign Orientation on every Stackpanel).

    Read the article

  • Function return type style

    - by JB
    I'm learning c++0x, at least the parts supported by the Visual C++ Express 2010 Beta. This is a question about style rather than how it works. Perhaps it's too early for style and good practice to have evolved yet for a standard that isn't even released yet... In c++0x you can define the return type of a method using - type at the end of the function instead of putting the type at the start. I believe this change in syntax is required due to lambdas and some use cases of the new decltype keyword, but you can use it anywhere as far as I know. // Old style int add1(int a, int b) { return a + b; } // New style return type auto add2(int a, int b) -> int { return a + b; } My question really then, is given that some functions will need to be defined in the new way is it considered good style to define all functions in this way for consistency? Or should I stick to only using it when necessary?

    Read the article

  • Coding with laptop and external screen - neck, back, comfort ...

    - by Xorty
    Guess I'm not the only one here coding on laptop + external keyboard + external screen. I can't really decide. Figure 1: Putting screen directly in front of (upright) my eyes and move laptop to the side. That feels like more comfortable but I can't really see so good to 15" laptop which is now quite away. Feels unused. Figure 2: Putting laptop in front of me and move external monitor on side. Feels like more efficient space usage, but I am afraid that my neck/back might start hurting since I need to turn my head often. What do you prefer? Some good advice? Sacrificing health is definitely no option here so that's why I'm worried and asking this silly question. Thanks

    Read the article

  • Consolidating coding styles: Funcs, private method, single method classes

    - by jdoig
    Hi all, We currently have 3 devs with, some, conflicting styles and I'm looking for a way to bring peace to the kingdom... The Coders: Foo 1: Likes to use Func's & Action's inside public methods. He uses actions to alias off lengthy method calls and Func's to perform simple tasks that can be expressed in 1 or 2 lines and will be used frequently through out the code Pros: The main body of his code is succinct and very readable, often with only one or 2 public methods per class and rarely any private methods. Cons: The start of methods contain blocks of lambda rich code that other developers don't enjoy reading; and, on occasion, can contain higher order functions that other dev's REALLY don't like reading. Foo 2: Likes to create a private method for (almost) everything the public method will have to do . Pros: Public methods remain small and readable (to all developers). Cons: Private methods are numerous. With private methods that call into other private methods, that call into... etc, etc. Making code hard to navigate. Foo 3: Likes to create a public class with a, single, public method for every, non-trivial, task that needs performing, then dependency inject them into other objects. Pros: Easily testable, easy to understand (one object, one responsibility). Cons: project gets littered by classes, opening multiple class files to understand what code does makes navigation awkward. It would be great to take the best of all these techniques... Foo-1 Has really nice, readable (almost dsl-like) code... for the most part, except for all the Action and Func lambda shenanigans bulked together at the start of a method. Foo-3 Has highly testable and extensible code that just feels a bit "belt-&-braces" for some solutions and has some code-navigation niggles (constantly hitting F12 in VS and opening 5 other .cs files to find out what a single method does). And Foo-2... Well I'm not sure I like anything about the one-huge .cs file with 2 public methods and 12 private ones, except for the fact it's easier for juniors to dig into. I admit I grossly over-simplified the explanations of those coding styles; but if any one knows of any patterns, practices or diplomatic-manoeuvres that can help unite our three developers (without just telling any of them to just "stop it!") that would be great. From a feasibility standpoint : Foo-1's style meets with the most resistance due to some developers finding lambda and/or Func's hard to read. Foo-2's style meets with a less resistance as it's just so easy to fall into. Foo-3's style requires the most forward thinking and is difficult to enforce when time is short. Any ideas on some coding styles or conventions that can make this work?

    Read the article

  • Recommended Reading for Polishing JavaScript coding style?

    - by wml653
    I've been coding in JavaScript for a while now and am fairly familiar with some of the more advanced coding features of the language (closures, self-executing functions, etc). So my question is, what advanced books/blogs/or anything else would be recommended to help tighten up my coding style? For example, recently I was coding something similar to: var x = ['a', 'b', 'c']; var exists = false; for(var i = 0; i < x.length; i++){ exists = x[i] === 'b' ? true : exists; } But found that the following condensed code would work better: var y = {'a':'', 'b':'', 'c':''}; var exists = 'b' in y; Both store the same value in 'exists', but the second is less common, but much cleaner. Any suggestions for where I should go to learn more tricks like this?

    Read the article

  • tips for fixing bad coding/dev habits ?

    - by dfafa
    i want to become a better coder....so i have decided to sign up for computing science program...maybe a formal education can assist me. i started working on smaller projects to learn but currently i have really bad coding/dev habits which is hindering my productivity as the codebase increases.... i have highlighted them and perhaps someone could make suggestions (or redirect to resources) or a more efficient method. most stuff that i made in the past were web apps. i usually develop with putty + nano...i just love the minimalist feel i use winscp and develop directly on my private web server...too lazy to do it on localhost and upload it later. i dont use subversion control...which one do i need ? sometimes ctrl +z doesn't work well. when i run out of ideas for naming variable, i use swear words instead. i swear a lot when i get stuck....how to deal with anger issue ? my codes look ugly with comments everywhere. would rather use procedural coding finds "thinking" in OO difficult and time consuming i "write first think later". refactors code only if i am getting paid for it. dislikes configuring linux distro, Apache, MySQL, scaling, designing graphics and layouts. does not like writing tests likes working alone. does not like sharing codes. has an econ degree dislikes reading other people's code would rather write it on my own it seems my only true desire is to translate my ideas to a working prototype as fast as possible....it seems like i am very uninterested in the other details...could it be that i am not cut out to be a coder after all ? is going back to study comp sci a bad idea ?

    Read the article

  • Questions on Juval Lowy's IDesign C# Coding Standard

    - by Jan
    We are trying to use the IDesign C# Coding standard. Unfortunately, I found no comprehensive document to explain all the rules that it gives, and also his book does not always help. Here are the open questions that remain for me (from chapter 2, Coding Practices): No. 26: Avoid providing explicit values for enums unless they are integer powers of 2 No. 34: Always explicitly initialize an array of reference types using a for loop No. 50: Avoid events as interface members No. 52: Expose interfaces on class hierarchies No. 73: Do not define method-specific constraints in interfaces No. 74: Do not define constraints in delegates Here's what I think about those: I thought that providing explicit values would be especially useful when adding new enum members at a later point in time. If these members are added between other already existing members, I would provide explicit values to make sure the integer representation of existing members does not change. No idea why I would want to do this. I'd say this totally depends on the logic of my program. I see that there is alternative option of providing "Sink interfaces" (simply providing already all "OnXxxHappened" methods), but what is the reason to prefer one over the other? Unsure what he means here: Could this mean "When implementing an interface explicitly in a non-sealed class, consider providing the implementation in a protected virtual method that can be overridden"? (see Programming .NET Components 2nd Edition, end of chapter “Interfaces and Class Hierarchies”). I suppose this is about providing a "where" clause when using generics, but why is this bad on an interface? I suppose this is about providing a "where" clause when using generics, but why is this bad on a delegate?

    Read the article

  • Is there an appropriate coding style for implementing an algorithm during an interview?

    - by GlenPeterson
    I failed an interview question in C years ago about converting hex to decimal by not exploiting the ASCII table if (inputDigitByte > 9) hex = inputDigitByte - 'a'. The rise of Unicode has made this question pretty silly, but the point was that the interviewer valued raw execution speed above readability and error handling. They tell you to review algorithms textbooks to prepare for these interviews, yet these same textbooks tend to favor the implementation with the fewest lines of code, even if it has to rely on magic numbers (like "infinity") and a slower, more memory-intensive implementation (like a linked list instead of an array) to do that. I don't know what is right. Coding an algorithm within the space of an interview has at least 3 constraints: time to code, elegance/readability, and efficiency of execution. What trade-offs are appropriate for interview code? How much do you follow the textbook definition of an algorithm? Is it better to eliminate recursion, unroll loops, and use arrays for efficiency? Or is it better to use recursion and special values like "infinity" or Integer.MAX_VALUE to reduce the number of lines of code needed to write the algorithm? Interface: Make a very self-contained, bullet-proof interface, or sloppy and fast? On the one extreme, the array to be sorted might be a public static variable. On the other extreme, it might need to be passed to each method, allowing methods to be called individually from different threads for different purposes. Is it appropriate to use a linked-list data structure for items that are traversed in one direction vs. using arrays and doubling the size when the array is full? Implementing a singly-linked list during the interview is often much faster to code and easier remember for recursive algorithms like MergeSort. Thread safety - just document that it's unsafe, or say so verbally? How much should the interviewee be looking for opportunities for parallel processing? Is bit shifting appropriate? x / 2 or x >> 1 Polymorphism, type safety, and generics? Comments? Variable and method names: qs(a, p, q, r) vs: quickSort(theArray, minIdx, partIdx, maxIdx) How much should you use existing APIs? Obviously you can't use a java.util.HashMap to implement a hash-table, but what about using a java.util.List to accumulate your sorted results? Are there any guiding principals that would answer these and other questions, or is the guiding principal to ask the interviewer? Or maybe this should be the basis of a discussion while writing the code? If an interviewer can't or won't answer one of these questions, are there any tips for coaxing the information out of them?

    Read the article

  • More elegant way to avoid hard coding the format of a a CSV file?

    - by dsollen
    I know this is trivial issue, but I just feel this can be more elegant. So I need to write/read data files for my program, lets say they are CSV for now. I can implement the format as I see fit, but I may have need to change that format later. The simply thing to do is something like out.write(For.getValue()+","+bar.getMinValue()+","+fi.toString()); This is easy to write, but obviously is guilty of hard coding and the general 'magic number' issue. The format is hard-coded, requires parsing of the code to figure out the file format, and changing the format requires changing multiple methods. I could instead have my constants specifying the location that I want each variable to be saved in the CSV file to remove some of the 'magic numbers'; then save/load into the an array at the location specified by the constants: int FOO_LOCATION=0; int BAR_MIN_VAL_LOCATION=1; int FI_LOCATION=2 int NUM_ARGUMENTS=3; String[] outputArguments=new String[NUM_ARGUMENTS]; outputArguments[FOO_LOCATION] = foo.getValue(); outputArgumetns[BAR_MIN_VAL_LOCATION] = bar.getMinValue(); outptArguments[FI_LOCATOIN==fi.toString(); writeAsCSV(outputArguments); But this is...extremely verbose and still a bit ugly. It makes it easy to see the format of existing CSV and to swap the location of variables within the file easily. However, if I decide to add an extra value to the csv I need to not only add a new constant, but also modify the read and write methods to add the logic that actually saves/reads the argument from the array; I still have to hunt down every method using these variables and change them by hand! If I use Java enums I can clean this up slightly, but the real issue is still present. Short of some sort of functional programming (and java's inner classes are too ugly to be considered functional) I still have no obvious way of clearly expressing what variable is associated with each constant short of writing (and maintaining) it in the read/write methods. For instance I still need to write somewhere that the FOO_LOCATION specifies the location of foo.getValue(). It seems as if there should be a prettier, easier to maintain, manner for approaching this? Incidentally, I'm working in java at the moment, however, I am interested conceptually about the design approach regardless of language. Some library in java that does all the work for me is definitely welcome (though it may prove more hassle to get permission to add it to the codebase then to just write something by hand quickly), but what I'm really asking is more about how to write elegant code if you had to do this by hand.

    Read the article

  • Common coding style for Python?

    - by Oscar Carballal
    Hi, I'm pretty new to Python, and I want to develop my first serious open source project. I want to ask what is the common coding style for python projects. I'll put also what I'm doing right now. 1.- What is the most widely used column width? (the eternal question) I'm currently sticking to 80 columns (and it's a pain!) 2.- What quotes to use? (I've seen everything and PEP 8 does not mention anything clear) I'm using single quotes for everything but docstrings, which use triple double quotes. 3.- Where do I put my imports? I'm putting them at file header in this order. import sys import -rest of python modules needed- import whatever import -rest of application modules- <code here> 4.- Can I use "import whatever.function as blah"? I saw some documents that disregard doing this. 5.- Tabs or spaces for indenting? Currently using 4 spaces tabs. 6.- Variable naming style? I'm using lowercase for everything but classes, which I put in camelCase. Anything you would recommend?

    Read the article

  • iPhone/Cocoa Coding Standards

    - by greypoint
    Are there any generally-accepted coding standards (naming, casting etc) that apply specifically to iPhone/Cocoa/Objective-C? I know Microsoft has published similar standards as they relate to .Net and C# but haven't run across anything related to the iPhone world.

    Read the article

  • Java coding style

    - by folone
    How do you keep yourself coding to standards? There is stylecop and resharper for C#. Are there any tools/eclipse plugins for code analisys in Java? Which of them do you use?

    Read the article

  • PHP Coding styles return; in switch/case

    - by ArneRie
    Hi , we're trying to implement new coding style guidelines for our team, the php codesniffer is printing an warning on switch case statements when no "break" is found like: switch ($foo) { case 1: return 1; case 2: return 2; default: return 3; } is there any good reason to use : switch ($foo) { case 1: return 1; break; } ?? the break is never reached ?

    Read the article

  • C# coding standards for private member variables [closed]

    - by Sasha
    I saw two common approaches for coding standards for private member variables: class Foo { private int _i; private string _id; } and class Foo { private int m_i; private string m_id; } I believe the latter is coming from C++. Also, many people specify type before the member variable: double m_dVal -- to indicate that is is a nonconstant member variable of the type double? What are the conventions in C#?

    Read the article

  • CSS style refresh in IE after dynamic removal of style link

    - by rybz
    Hi! I've got a problem with the dynamic style manipulation in IE7 (IE8 is fine). Using javascript I need to add and remove the < link / node with the definition of css file. Adding and removing the node as a child of < head / works fine under Firefox. Unfortunately, after removing it in the IE, although The tag is removed properly, the page style does not refresh. In the example below a simple css (makes background green) is appended and removed. After the removal in FF the background turns default, but in IE stays green. index.html <html> <head> </head> <script language="javascript" type="text/javascript"> var node; function append(){ var headID = document.getElementsByTagName("head")[0]; node = document.createElement('link'); node.type = 'text/css'; node.rel = 'stylesheet'; node.href = "s.css"; node.media = 'screen'; headID.appendChild(node); } function remove(){ var headID = document.getElementsByTagName("head")[0]; headID.removeChild(node); } </script> <body> <div onClick="append();"> add </div> <div onClick="remove();"> remove </div> </body> </html> And the style sheet: s.css body { background-color:#00CC33 } Here is the live example: http://rlab.pl/dynamic-style/ Is there a way to get it working?

    Read the article

  • Netbeans styles. Are there style profiles similar to Notepad++?

    - by Djeman
    Not long ago I started to use Ubuntu. When I was on Windows I used Notepad++. I was very surprised when I found that Notepad++ is only for Windows. So I installed Netbeans. Netbeans is a powerful IDE and in general I like it, except default styles. Maybe are there style profiles (i.e. plugins or other forms)? It would be good if there is a style profile completely identical to Notepad++. I will be very thankful if you would help me to find what I'm looking for.

    Read the article

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