Search Results

Search found 5688 results on 228 pages for 'newbie programmer'.

Page 15/228 | < Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >

  • Taking "do the simplest thing that could possible work" too far in TDD: testing for a file-name kno

    - by Support - multilanguage SO
    For TDD you have to Create a test that fail Do the simplest thing that could possible work to pass the test Add more variants of the test and repeat Refactor when a pattern emerge With this approach you're supposing to cover all the cases ( that comes to my mind at least) but I'm wonder if am I being too strict here and if it is possible to "think ahead" some scenarios instead of simple discover them. For instance, I'm processing a file and if it doesn't conform to a certain format I am to throw an InvalidFormatException So my first test was: @Test void testFormat(){ // empty doesn't do anything nor throw anything processor.validate("empty.txt"); try { processor.validate("invalid.txt"); assert false: "Should have thrown InvalidFormatException"; } catch( InvalidFormatException ife ) { assert "Invalid format".equals( ife.getMessage() ); } } I run it and it fails because it doesn't throw an exception. So the next thing that comes to my mind is: "Do the simplest thing that could possible work", so I : public void validate( String fileName ) throws InvalidFormatException { if(fileName.equals("invalid.txt") { throw new InvalidFormatException("Invalid format"); } } Doh!! ( although the real code is a bit more complicated, I found my self doing something like this several times ) I know that I have to eventually add another file name and other test that would make this approach impractical and that would force me to refactor to something that makes sense ( which if I understood correctly is the point of TDD, to discover the patterns the usage unveils ) but: Q: am I taking too literal the "Do the simplest thing..." stuff?

    Read the article

  • Career advice for a frustrated newbie programmer.

    - by Satoru.Logic
    Hi, all. This is my first year as a programmer. The programming language that I'm most familiar with is Python. I am maintaining a web2py based legacy system, alone, which means I have to grow up as an all-rounder. The original programmers on this project are nowhere to find, and there are hardly any usable documents about requirements or anything. I find it very frustrating every time I hear the users criticize the system, and I can't help explaining that "that was not my fault, those mess was there even before I entered this company." I wonder what should I do with this situation. Please give me some advice, thanks in advance.

    Read the article

  • jquery full calendar

    - by madrat
    hello everybody. I am new to fullCalendar and i do not kno how to use gotoDate method. What i have is a tabbed page with 12 tabs (every tab is a month of the year). What i need is when i load jquery calendar, foreach tab, the calendar to switch to the month that is assigned. (e.g when i click and load page for January the calendar shows days for january, and so on). thanks for your help.

    Read the article

  • What exactly are tuples in Python?

    - by Sergio Tapia
    I'm following a couple of Pythone exercises and I'm stumped at this one. # C. sort_last # Given a list of non-empty tuples, return a list sorted in increasing # order by the last element in each tuple. # e.g. [(1, 7), (1, 3), (3, 4, 5), (2, 2)] yields # [(2, 2), (1, 3), (3, 4, 5), (1, 7)] # Hint: use a custom key= function to extract the last element form each tuple. def sort_last(tuples): # +++your code here+++ return What is a Tuple? Do they mean a List of Lists?

    Read the article

  • I want to better organize my website files, but I can access the .php files using the folder heirarc

    - by Sergio Tapia
    For example, to access a page in my search folder, I have to write: mywebsite.tld/search/searchJob.php I don't want users to have to write down folder structure and whatnot. What can I do to change this? OR, is there a better way to organize my files? Because I'm only two pages in and I decided to move some files and got lost in the heirarchy (that's why I moved them like in the picture).

    Read the article

  • What about Programmer "Invisible" registers?

    - by claws
    These are "Programmer Visible" x86-64 registers: What about the invisible registers? Just now I learned that MMU registers, Interrupt Descriptor Table (IDT) uses these invisible registers. I'm learning these things in the hard way. Is there any resource (book/documentation/etc) that gives me the complete picture at once? I am aware of the programmer visible registers and comfortable in programming with them. I just want to learn about invisible registers and their functionality. I want to get a complete picture. Where can I get this info?

    Read the article

  • Generic collection as a Java method argument

    - by Guido
    Is there any way to make this work in Java? public static void change(List<? extends Object> list, int position1, int position2) { Object obj = list.get(position1); list.set(position1, list.get(position2)); list.set(position2, obj); } The only way I've successfully avoided warnings and errors is this: public static <T> T change(List<T> list, int position1, int position2) { T obj = list.get(position1); list.set(position1, list.get(position2)); list.set(position2, obj); return obj; } but I don't like to be forced to return a value.

    Read the article

  • Help a Python newbie with a Django model inheritance problem

    - by Joshmaker
    I'm working on my first real Django project after years of PHP programming, and I am running into a problem with my models. First, I noticed that I was copying and pasting code between the models, and being a diligent OO programmer I decided to make a parent class that the other models could inherit from: class Common(model.Model): self.name = models.CharField(max_length=255) date_created = models.DateTimeField(auto_now_add=True) date_modified = models.DateTimeField(auto_now=True) def __unicode__(self): return self.name class Meta: abstract=True So far so good. Now all my other models extend "Common" and have names and dates like I want. However, I have a class for "Categories" were the name has to be unique. I assume there should be a relatively simple way for me to access the name attribute from Common and make it unique. However, the different methods I have tried to use have all failed. For example: class Category(Common): def __init__(self, *args, **kwargs): self.name.unique=True Spits up the error "Caught an exception while rendering: 'Category' object has no attribute 'name' Can someone point me in the right direction?

    Read the article

  • How do you clear the focus in javascript?

    - by Andres
    I know this shouldn't be that hard, but I couldn't find the answer on Google. I want to execute a piece of javascript that will clear the focus from whatever element it is on without knowing ahead of time which element the focus is on. It has to work on firefox 2 as well as more modern browsers. Is there a good way to do this?

    Read the article

  • Drupal: How long should it take to rebuild permissions

    - by Shaun
    Hi, I have just installed the ACL and Content Access module. Imedietly after enabling them I was asked to rebuild the permissions. All perfectly normal I am told. However, I set the 'rebuild' permissions page running about 40 minutes ago and it still says 'Initializing'. How long should it take? Am I doing something wrong?

    Read the article

  • Python 2.5.2: trying to open files recursively

    - by user248959
    Hi, the script below should open all the files inside the folder 'pruebaba' recursively but i get this error: Traceback (most recent call last): File "/home/tirengarfio/Desktop/prueba.py", line 8, in f = open(file,'r') IOError: [Errno 21] Is a directory This is the hierarchy: pruebaba folder1 folder11 test1.php folder12 test1.php test2.php folder2 test1.php The script: import re,fileinput,os path="/home/tirengarfio/Desktop/pruebaba" os.chdir(path) for file in os.listdir("."): f = open(file,'r') data = f.read() data = re.sub(r'(\s*function\s+.*\s*{\s*)', r'\1echo "The function starts here."', data) f.close() f = open(file, 'w') f.write(data) f.close() Any idea? Regards Javi

    Read the article

  • Bundle module with app on Google App Engine

    - by Oscar Reyes
    This may be a basic question but how can I include a module with my app. I'm very new to python and what I want to do is to include this module simplejson with my app, but after downloading it I have no idea what to do next :( This is how the module looks like after unzip it. I don't know what files to move to my app.

    Read the article

  • Shutdown and WakeUp Script C#

    - by Stephen Murby
    Hiya I am very new to C#, infact this is basically my first task set by work whilst i learn the language. Yes i am also new to programming, be gentle :). Context: My script needs to query active directory, grab of OU's and put them to a combo box in a form. Next query ActDir for a list of machines in a selected OU (Done this in a vbscript already) Next query the machines in turn for there IP, and MAC addresses.(Done this in a vbscript already) Next needs to shut those machines down(Done this in a vbscript already) and dump all the machine and NIC info to a txt file The other half of the script grabs the info for the machines out of the text file and sends them a magic packet to wake them up. The shutdown section i have already written a VBscript for, but decided it wasn't future prrof, and i was learninc C# at home, so figured it was the best option to start over with. Im not looking for anyone to write this for me, but if anyone had any pointers on where to go for information etc. . . It would be more than appreciated :)

    Read the article

  • git-svn merge 2 svn branches

    - by idimba
    I using svn. I have two branches and on both of them were performed a lot of changes. In addition of one of the branches a lot of files were renamed, so now svn can not help me merge changes in those files (well know svn limitation). Is it possible using git-svn to perform the merge of the branches? Will git-svn hanndle renamed files too? Thanks

    Read the article

  • Why can't I install psycopg2? (Python 2.6.4, PostgreSQL 8.4, OS X 10.6.3)

    - by cojadate
    UPDATE: After updating all my software, the error message has changed. Now, when I run "python setup.py install" I get the following: Warning: Unable to find 'pg_config' filebuilding 'psycopg2._psycopg' extension gcc-4.0 -arch ppc -arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 -DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.1 (dt dec ext pq3)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -c psycopg/psycopgmodule.c -o build/temp.macosx-10.3-fat-2.6/psycopg/psycopgmodule.o followed by a very long list of other error messages. After running python setup.py install I get the following: Warning: Unable to find 'pg_config' filebuilding 'psycopg2._psycopg' extension gcc-4.0 -arch ppc -arch i386 -fno-strict-aliasing -fno-common -dynamic -DNDEBUG -g -O3 - DPSYCOPG_DEFAULT_PYDATETIME=1 -DPSYCOPG_VERSION="2.2.1 (dt dec ext pq3)" -DPSYCOPG_EXTENSIONS=1 -DPSYCOPG_NEW_BOOLEAN=1 -DHAVE_PQFREEMEM=1 -DHAVE_PQPROTOCOL3=1 -I/Library/Frameworks/Python.framework/Versions/2.6/include/python2.6 -I. -c psycopg/psycopgmodule.c -o build/temp.macosx-10.3-fat-2.6/psycopg/psycopgmodule.o unable to execute gcc-4.0: No such file or directory error: command 'gcc-4.0' failed with exit status 1 There's probably something screamingly obvious there to anyone who knows the first thing about back-end web programming, but unfortunately it's all gobbledegook to me. The psycopg2 documentation was not helpful.

    Read the article

  • Project Euler #290 in python, hint please

    - by debragail
    This solution is grossly inefficient. What am I missing? #!/usr/bin/env python #coding: utf-8 import time from timestrings import * start = time.clock() maxpower = 18 count = 0 for i in range(0, 10 ** maxpower - 1): if i % 9 == 0: result1 = list(str(i)) result2 = list(str(137 * i)) sum1 = 0 for j in result1: sum1 += int(j) sum2 = 0 for j in result2: sum2 += int(j) if sum1 == sum2: print (i, sum1) count += 1 finish = time.clock() print ("Project Euler, Project 290") print () print ("Answer:", count) print ("Time:", stringifytime(finish - start))

    Read the article

  • Does height and width not apply to span?

    - by Kyle Sevenoaks
    Total noob question, but here. CSS .product__specfield_8_arrow { /*background-image:url(../../upload/orng_bg_arrow.png); background-repeat:no-repeat;*/ background-color:#fc0; width:50px !important; height:33px !important; border: 1px solid #dddddd; border-left:none; border-radius:5px; -moz-border-radius:5px; -webkit-border-radius:5px; border-bottom-left-radius:0px; border-top-left-radius:0px; -moz-border-radius-bottomleft:0px; -moz-border-radius-topleft:0px; -webkit-border-bottom-left-radius:0px; -webkit-border-top-left-radius:0px; margin:0; padding:2px; cursor:pointer; }??? HTML <span class="product__specfield_8_arrow">&nbsp;</span>? Fiddle Basically I'm trying to emulate a button, make a span (or something) look like a button next to an input field that actually doesn't need to be one because of an auto fill generator that generates errors onEnter. Thought this'd be a quick fix for now but obviously not. Thanks.

    Read the article

  • What should every programmer know?

    - by Matt Lacey
    Regardless of programming language(s) or operating system(s) used or the environment they develop for, what should every programmer know? Some background: I'm interested in becoming the best programmer I can. As part of this process I'm trying to understand what I don't know and would benefit me a lot if I did. While there are loads of lists around along the lines of "n things every [insert programming language] developer should know", I have yet to find anything similar which isn't limited to a specific language. I also expect this information to be of interest and benefit to others.

    Read the article

  • Efficient splitting of elements in a field

    - by Gary
    I have a field in a text file exported from a database. The field contains addresses but sometimes they are quite long and the database allows them to contain multiple lines. When exported, the newline character gets replaced with a dollar sign like this: first part of very long address$second part of very long address$third part of very long address Not every address has multiple lines and no address contains more than three lines. The length of each line is variable. I'm massaging the data for import into MS Access which is used for a mailmerge. I want to split the field on the $ sign if it's there but if the field only contains 1 line, I want to set my two extra output fields to a zero length string so that I don't wind up with blank lines in the address when it gets printed. I have an awk file that's working correctly on all the other data in the textfile but I need to get this last bit working. I tried the below code. Aside from the fact that I get a syntax error at the else, I'm not sure this is a good way to do what I want. This is being done with gawk on Windows. BEGIN { FS = "|" } $1 != "HEADER" { if ($6 ~ /\$/) split($6, arr, "$") address = arr[1] addresstwo = arr[2] addressthree = arr[3] addressLength = length(address) addressTwoLength = length(addresstwo) addressThreeLength = length(addressthree) else { address = $6 addressLength = length($6) addresstwo = "" addressTwoLength = length(addresstwo) addressthree = "" addressThreeLength = length(addressthree) } printf("%*s\t%*s\t\%*s\n", addressLength, address, addressTwoLength, addresstwo, addressThreeLength, addressthree) }

    Read the article

< Previous Page | 11 12 13 14 15 16 17 18 19 20 21 22  | Next Page >