Subjects
PRICING
COURSES
SIGN IN
Start Free Trial
Eleanor H.
Professional Software Developer for the State of Indiana
Tutor Satisfaction Guarantee
Web Development
TutorMe
Question:

How should one debug a web page that is not properly binding values from the server?

Eleanor H.
Answer:

First thing is first: eliminate the obvious. In a given application or environment, there's usually a short list of things that are, too often, the cause of the problem. Are you sure your connection string says exactly what it should? Have you made suspicious changes recently to a legacy class the data depends on? Is there a script that does a little too much on the client side? If you've recently found one bug in a give code block, there may well be more, so round up the usual suspects. After that, do a binary search. Start in your controller or code-behind and check the values there. If they are not there, move backward and check your repository layer; otherwise, move forwards and check your front-end scripts. Not in the repository layer either? Check your database table. If it's there, you know the problem is the database procedure that feeds the repository layer. The trick is to think of the stack as linear and keep aiming for halfway in-between where behavior is as expected and where it is not. Just like a binary search is the fastest way to search for a number in a list, so it is the fastest way to find a bug in a web stack.

Databases
TutorMe
Question:

Unlike Transact-SQL, Oracle SQL has no way to represent boolean values in a database table column (in keeping with ANSI SQL). What is the best way to represent a flag in an Oracle relational database?

Eleanor H.
Answer:

It isn't my understanding that Oracle itself has an official convention for dealing with these flags. However, I believe that there is an objectively best practice. Many people solve this problem by encoding a single character as a value. I believe this is a weak solution for a couple of reasons. First, an organization would have to choose and commit to a convention for flags. Will the organization use 'Y' and 'N' for "Yes" and "No" or 'T' and 'F' for "true" and "false." What about context-specific flag abbreviations like 'A' and 'I' for "active" and "inactive?" Should it be case-sensitive or not? The column type is too nebulous to really tell you what should be valid values. Secondly, by default, it leaves the database open to unexpected values. Say that an organization has committed to 'Y' and 'N' as their flag encodings, but a clumsy database developer accidentally hits 'B' (next to 'N' on the keyboard). This meaningless data will not be picked up either by a query for 'Y' nor a query for 'N.' The unexpected character problem can be overcome by custom constraints, but this isn't highly intuitive behavior and should therefore be avoided if there is a better solution, and I believe there is. In my understanding, the best solution is to use a nonnullable NUMBER(1). This database column is descriptive; it takes only 1 and 0 as possible values. As a bonus, it is entirely language agnostic so that a non-English speaker would not have to know that the letter 'Y' stands for the English word "Yes." Further, it takes up a lot less space (though this is rarely a consideration) because a character takes up many bits whereas a NUMBER(1) only takes up one bit. More importantly, it is far more performant because numeric comparisons perform much better than string comparisons, which should be avoided as often as possible. Also, insofar as it is relevant, the NUMBER(1) is Entity-Framework compatible; the C# native values true and false will map to 1 and 0. Most importantly, though, I would appeal to the basic ontology of boolean values. Booleans are numbers. Boolean operations are not string operations; they are fundamentally addition (OR) and multiplication (AND). Therefore, the operands are numbers. This by itself doesn't confer any practical benefit to using NUMBER(1) (as opposed to speed or disk space or Entity-Framework compatibility) but it is still important because sticking to fundamental truths makes for better math and, ultimately, better applications.

Computer Science (General)
TutorMe
Question:

Write a good fizzbuzz in pseudocode.

Eleanor H.
Answer:

/* returns a string representation of numbers 0 * through n where numbers divisible by three are * represented by "fizz," numbers divisible by five * are represented by "buzz," and numbers * divisible by three and five are represented by * "fizzbuzz." */ public string fizzbuzz(int n) { StringBuilder sb = new StringBuilder(); for (int i = 0; i <= n; i++) { sb.append(toFizzbuzzString(i); } return sb.toString(); } /* helper method of fizzbuzz(n); returns a string * representation of k according to the conventional * rules of fizzbuzz. */ private string toFizzbuzzString(int k) { string result = ""; if (k % 3 == 0) { result += "fizz"; } if (k % 5 == 0) { result += "buzz"; } if (result == "") { result = k.toString(); } return result; }

Send a message explaining your
needs and Eleanor will reply soon.
Contact Eleanor
Ready now? Request a lesson.
Start Session
FAQs
What is a lesson?
A lesson is virtual lesson space on our platform where you and a tutor can communicate. You'll have the option to communicate using video/audio as well as text chat. You can also upload documents, edit papers in real time and use our cutting-edge virtual whiteboard.
How do I begin a lesson?
If the tutor is currently online, you can click the "Start Session" button above. If they are offline, you can always send them a message to schedule a lesson.
Who are TutorMe tutors?
Many of our tutors are current college students or recent graduates of top-tier universities like MIT, Harvard and USC. TutorMe has thousands of top-quality tutors available to work with you.