Sponsored Content
Full Discussion: Naive coding...
The Lounge What is on Your Mind? Naive coding... Post 302992179 by Corona688 on Wednesday 22nd of February 2017 10:47:19 AM
Old 02-22-2017
Quote:
Originally Posted by wisecracker
"Naive coding."
(Apologies for any typos.)

I came across this phrase a couple of weeks ago and it has made me decide to set off a discussion.

I had never heard of it before but I did some research and discovered that I probably fall into this category.

My phrase is: "I code to work, not work to code!", so therefore I guess when viewing any of my code, pros' must think how primitive some of it looks.

So, what do you guys who code for a living think when you see some attempts of others solving problems and use _brute_force_methods_ for example to solve their coding problems when there are probably more elegant solutions?
For one-off scripts and things you only do once, nothing wrong with it. You're writing code to solve a problem, and if the problem's solved to your own satisfaction without severe side effects, who cares?

The problem is, coding that way, with no effort to learn further, builds bad habits. Naive methods are not applicable to all situations, or even most situations. If you only have the heavy-duty sledgehammer in your toolbox, you'll break all the smaller nails.
Quote:
Also what is wrong with a naive solution that works for the coder although it may not be anywhere near as fast as another method more obvious to someone else?
You're building audioscope.sh as a teaching tool. You've eschewed many modern features because you consider them hard to read.

I think reducing it to a quarter of its length, could make it easier to read.
Quote:
The plotting and drawing routines for example on AudioScope can't seem to be done any other way except by _brute_force_...
Saying so doesn't make it so. You've fought tooth-and-claw against anyone who tries to optimize it.
 

7 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

can I use this coding

I apologise because I had pasted this question in the newbies forum first (because i am a bit of a newbie) but thought it might be better suited in here if i have to sepearate parameters can I use this syntax especially the or part (||) and is this correct if (6 Replies)
Discussion started by: w33man
6 Replies

2. Shell Programming and Scripting

Coding on my Mac

I would like to start coding on my mac, but I'm getting an error when I attempt to execute my script -bash : testscript: command not found I have verified that the #! line points to the correct directory. If you have some insight it would be greatly appreciated! - D (1 Reply)
Discussion started by: DKNUCKLES
1 Replies

3. UNIX for Dummies Questions & Answers

pro*c coding

Hi All, I am new to pro*C. I have a select statement as select a.ename,a.sal,a.empno from emp where &n=(select count(distinct(b.sal)) from emp b where a.sal<=b.sal for this query I have to write a pro*C program. So can you please send me the complete code. Then I will foloow the same... (1 Reply)
Discussion started by: user71408
1 Replies

4. Homework & Coursework Questions

Naive Bayes

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: I have to write a program in Unix to do the following.Given a phrase like george hates john, by... (0 Replies)
Discussion started by: gizmo87
0 Replies

5. Shell Programming and Scripting

Need help with coding

HI, Can some one guide me how to make changes to the script below so that it can load the history of a program to IT server ? Format of data: YYYYMMDD065959.dsk.log YYYYMMDD235959.dsk.log currently both are loaded together. Need to separate them as above format. Thanks in advance. ... (1 Reply)
Discussion started by: crazydude80
1 Replies

6. Windows & DOS: Issues & Discussions

Need help with coding

HI, Can some one guide me how to make changes to the script below so that it can load the history of a program to IT server ? Format of data: YYYYMMDD065959.dsk.log YYYYMMDD235959.dsk.log currently both are loaded together. Need to separate them as above format. Thanks in advance. ... (2 Replies)
Discussion started by: crazydude80
2 Replies

7. Shell Programming and Scripting

HTTP coding

My company has an in house instant messaging system (like WhatsApp) where users can communicate with each other. I currently have code to email me certain items from my Sparc machine running SunOS 5.10. I want what I am emailing myself to now instant message me. The team that created the messenger... (5 Replies)
Discussion started by: shorty
5 Replies
OCI_FIELD_SIZE(3)														 OCI_FIELD_SIZE(3)

oci_field_size - Returns field's size

SYNOPSIS
int oci_field_size (resource $statement, mixed $field) DESCRIPTION
Returns the size of a $field. PARAMETERS
o $statement - A valid OCI statement identifier. o $field - Can be the field's index (1-based) or name. RETURN VALUES
Returns the size of a $field in bytes, or FALSE on errors. EXAMPLES
Example #1 oci_field_size(3) example <?php // Create the table with: // CREATE TABLE mytab (number_col NUMBER, varchar2_col varchar2(1), // clob_col CLOB, date_col DATE); $conn = oci_connect("hr", "hrpwd", "localhost/XE"); if (!$conn) { $m = oci_error(); trigger_error(htmlentities($m['message']), E_USER_ERROR); } $stid = oci_parse($conn, "SELECT * FROM mytab"); oci_execute($stid, OCI_DESCRIBE_ONLY); // Use OCI_DESCRIBE_ONLY if not fetching rows echo "<table border="1"> "; echo "<tr>"; echo "<th>Name</th>"; echo "<th>Type</th>"; echo "<th>Length</th>"; echo "</tr> "; $ncols = oci_num_fields($stid); for ($i = 1; $i <= $ncols; $i++) { $column_name = oci_field_name($stid, $i); $column_type = oci_field_type($stid, $i); $column_size = oci_field_size($stid, $i); echo "<tr>"; echo "<td>$column_name</td>"; echo "<td>$column_type</td>"; echo "<td>$column_size</td>"; echo "</tr> "; } echo "</table> "; // Outputs: // Name Type Length // NUMBER_COL NUMBER 22 // VARCHAR2_COL VARCHAR2 1 // CLOB_COL CLOB 4000 // DATE_COL DATE 7 oci_free_statement($stid); oci_close($conn); ?> NOTES
Note In PHP versions before 5.0.0 you must use ocicolumnsize(3) instead. This name still can be used, it was left as alias of oci_field_size(3) for downwards compatability. This, however, is deprecated and not recommended. SEE ALSO
oci_num_fields(3), oci_field_name(3). PHP Documentation Group OCI_FIELD_SIZE(3)
All times are GMT -4. The time now is 12:31 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy