topbanner_forum
  *

avatar image

Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
  • Saturday November 15, 2025, 12:36 pm
  • Proudly celebrating 15+ years online.
  • Donate now to become a lifetime supporting member of the site and get a non-expiring license key for all of our programs.
  • donate

Recent Posts

Pages: prev1 ... 17 18 19 20 21 [22] 23 24 25 26 27 ... 46next
526
General Software Discussion / Re: Good coding conventions - Discussion
« Last post by Jibz on January 03, 2013, 07:47 AM »
When it comes to naming conventions, I largely adhere to when in Rome. Personally, I prefer lowercase with underscores. I am not terribly fond of Hungarian notationw -- I feel 90% of the time it is extra typing with no benefit. I can see some benefit in CamelCasew for long names, as long as your editor has some kind of auto-completion, but like f0dder puts it:

If you end up with method names that are long or weird, that's often a good indication of a code smell.

I prefer well-named and small (private) functions/methods over comments. Comments are fine for documenting your public APIs, as well as some implementation details, quirks and hacky workarounds - but other than that, I prefer to split into small and well-defined steps, and let the code speak for itself.

I must admit, I am a big fan of comments :-[. I believe commenting the "intent" of your code is usually worth it. There is not a lot of code outside of textbooks that is really self-documenting, and what seems obvious to you while you are writing the code may take a little time for the next coder (or yourself in a month or two) to figure out. Reading a short line of text is always easier than interpreting a few lines of code. Also, when you look at a function, I think it is a lot easier to grasp what it does if you can skim over it only reading the comment lines (which most text editors highlight in some way), and that gives you a kind of "storyboard". As an example, if you take this simple function

Code: C [Select]
  1. BOOL sut_open(SUPTIME *sut)
  2. {
  3.     wchar_t szCounterPath[PDH_MAX_COUNTER_PATH + 1];
  4.  
  5.     if (sut == NULL) return FALSE;
  6.  
  7.     /* construct path to localized system up time counter */
  8.     if (!make_counterpath(szCounterPath, sizeof(szCounterPath) / sizeof(szCounterPath[0]))) return FALSE;
  9.  
  10.     /* check path is valid */
  11.     if (PdhValidatePath(szCounterPath) != ERROR_SUCCESS) return FALSE;
  12.  
  13.     /* create query */
  14.     if (PdhOpenQuery(NULL, 0, &sut->hQuery) != ERROR_SUCCESS) return FALSE;
  15.  
  16.     /* add counter to query */
  17.     if (PdhAddCounter(sut->hQuery, szCounterPath, 0, &sut->hCounter) != ERROR_SUCCESS)
  18.     {
  19.         PdhCloseQuery(sut->hQuery);
  20.         return FALSE;
  21.     }
  22.  
  23.     return TRUE;
  24. }

and only read the comments you get

Code: C [Select]
  1. BOOL sut_open(SUPTIME *sut)
  2. {
  3.     /* construct path to localized system up time counter */
  4.  
  5.     /* check path is valid */
  6.  
  7.     /* create query */
  8.  
  9.     /* add counter to query */
  10. }

which sums up what it does. Granted, the single lines of code in that particular example are so simple here that you could probably easily understand the function without the comments if you know what the API calls do, but I am guessing it would still take you at least twice as long as just reading the comments.

And like you say, always make a comment about any hackish code, because even though you know how it magically does what it does right now, nobody (including you) will know in a month :huh:.

Use of the ternary operator doesn't mean I'm in the "as few lines of code as possible" camp, though. I often break condition of if-statements into (properly named) booleans or method calls, which obviously results in more code lines... but also in better readability.

I like and use the ternary operator as well, in some situations it lets you express more clearly what you want in less code. Of course you can make unreadable code with it as well, but it's always like that (with great power comes etc. ;D).

Btw, I don't know if it's GeSHI or Chrome, but it looks like most of the identifiers are raised a little above the line (or the operators and keywords lowered) in the code blocks, which is slightly annoying to read:

CamelCaseHighLight.png
527
N.A.N.Y. 2013 / Re: --> DonationCoder.com NANY 2013 Roundup Summary
« Last post by Jibz on January 03, 2013, 06:15 AM »
Congratulations all :Thmbsup:.
528
General Software Discussion / Re: Good coding conventions - Discussion
« Last post by Jibz on December 31, 2012, 11:37 AM »
Don't know if that had anything to do with it, but AFAIR hyphens were not (originally) allowed in filenames on CDs (ISO_9660w from 1988).
529
Great update :Thmbsup:.

I can't seem to get Autofit Form to Bars to do anything (running the portable version as a window) -- I expected it to scale the window so it fit the bars? Also, the default size it opens with cuts off the right side of the bars here.
530
Living Room / Re: New Windows install - How should I organize SSD, HDD, user folders?
« Last post by Jibz on December 31, 2012, 09:56 AM »
I'd say disable the pagefile (or relocate to your HDD; it shouldn't be hit that much with 12 gigs of ram, so you shouldn't see a speed hit). RAM disk for %TMP% and %TEMP% (both the system and user environment variables) is nice, not only does it reduce wear&tear on the SSD, but can be a nice speed increase of some things. I find that at 1gig ramdisk works pretty well for my TEMP and FireFox profile (backed up, of course). I use SoftPerfect now, persistent disk, and it works pretty well.

Have you ever run into any problems with installers or windows update like the ones mentioned here and here?

531
General Software Discussion / Re: Acronis Backup
« Last post by Jibz on December 23, 2012, 06:23 PM »
You often end up having to upgrade because you get a new version of Windows, or new external storage hardware that is incompatible with the older version.
532
General Software Discussion / Re: Acronis Backup
« Last post by Jibz on December 23, 2012, 01:02 PM »
I've generally heard good things about Paragon software .. what has always bugged me is how they seem to have 20 products with more or less overlapping functionality -- I can never figure out what exactly would be the right thing to get :-[.

Image for Windows is another one people generally praise, but it looks a bit like Ghost did 10 years ago.

I don't know which of them all you can really trust with your data anymore.
533
N.A.N.Y. 2013 / Re: N.A.N.Y. 2013 - RAT - Renegade Audio Transcoder
« Last post by Jibz on December 22, 2012, 07:15 AM »
Nice :Thmbsup:
534
Found Deals and Discounts / Re: Ad Muncher - half off
« Last post by Jibz on December 21, 2012, 04:33 PM »
i wonder what their new technologies are.  they said they would never address https, and a lot of google's stuff is going that way.  No big deal, but it makes the value of AM a little less.  What could they improve to make up for something like that?  curious...

I was thinking much the same.
535
By SoftMaker paying them for each download?

Basically SoftMaker is giving money to this charity (owned by SoftMaker?) in exchange for getting more people to download their freeware version.

Interestingly, this used to be the full commercial version in previous years.
536
Reserved.
537
NANY 2013 Entry Information

Application Nametmdiff
Short DescriptionA collection of C functions to aid in output of time differences
Supported OSesAnything with a decent C compiler.
Web Pagehttps://bitbucket.org/jibsen/tmdiff
Version Historyhttps://bitbucket.or...n/tmdiff/commits/all
AuthorJibz


Description

This is an attempt at solving the problem of formatting the difference between two points in time in a manner similar to the strftime() function. It was based on a discussion about PBoL.

The problem is; given a start date and time, and an end date and time, format a string with values showing the difference in years, months, days, hours, minutes, and seconds between the two.

Because months and years contain a varying number of days, we cannot simply compute these from difftime().

For instance, the difference between Jan 31st and Mar 1st is sometimes 29 days, sometimes 30 days, but always one month and one day. The difference between Jul 2nd and Aug 1st is 30 days, but not a month.

For a more detailed description of the problem, check this blog post.


Functions

tmdiff() is a low-level function that does the actual work of computing the time difference between two tm structs.

sftmdiff() and wsftmdiff() provide formatted output of the time difference between two tm structs.

asctmdiff() and wasctmdiff() provide a more generic textual representation.
538
I still think it would be a good idea to give the user the option of full controll via strftime. I can imagine there could be bars where you would prefer to always have the time left in say days instead of the smart setting. Would also make it easier to "localize" the bars for people outside US/GB.

i don't think it's as simple as you are suggesting -- remember this isn't a date/time that's being formatted -- it's an "elapsed time" or time "difference" ..  is there a strftime like function for that?

You are right, it turns out to not be as simple as I suggested. Mainly because the naive solution does not take into accound that years and months have a varying size -- what for instance is the difference between Jan 31st and Mar 1st? sometimes 29 days, sometimes 30 days, but always a month and a day. What about Jul 2nd to Aug 1st? 30 days, but not a month ;D.
539
Ok, here are some first thoughts from playing around with it:

First thing I noticed is how difficult it is to read the black text on the red bars, and to some extent the brown ones as well.

pbol_textonredbar.png

I still think it would be a good idea to give the user the option of full controll via strftime. I can imagine there could be bars where you would prefer to always have the time left in say days instead of the smart setting. Would also make it easier to "localize" the bars for people outside US/GB.

Perhaps an option to add a little spacing between the bars?

Is there an option somewhere to have it not always on top when windowed?

Would be nice if the right-click menu of the individual bars would let you open the properties for that bar.

The textual progress appears to only work for the modern visual theme.

The smooth visual theme has the "update glow" effect on it every time the bar is updated, which is slightly annoying.

I am guessing the visual themes are a new addition, since the colors are wrong as well.

It might be an idea to truncate percentages instead of rounding to avoid having bars show at 100% before the entire time has elapsed.

Some events are "full day", I am a little confused about what I should set the time at. Like my birthday, should is tart at 00:00:00 and end at 23:59:59 the same day next year?

Maybe the option to create bars that just count an amount of time with the ability to start/stop/reset? .. I am thinking along the lines of a "Take a 5 min break" bar that you could reset and start whenever you needed a break.

It's quite fun to play around with, good idea :Thmbsup:.


540
Living Room / Re: Reducing Scales - Recurring numbers & Patterns
« Last post by Jibz on December 05, 2012, 02:19 AM »
http://en.wikipedia....ki/Repeating_decimal

Rational numbers are numbers that can be expressed in the form a/b where a and b are integers and b is non-zero. This form is known as a common fraction. On the one hand, the decimal representation of a rational number is ultimately periodic, as explained below. On the other hand every real number which has an eventually periodic decimal expansion is a rational number. In other words the numbers with eventually repeating decimal expansions are exactly the rational numbers (i.e.: those that can be expressed as ratios).
541
N.A.N.Y. 2013 / Re: N.A.N.Y. 2013 Pledge & Release: 2x2 List Sorter
« Last post by Jibz on December 05, 2012, 01:50 AM »
Actually, I guess the user is the comparison function, so you could implement most sorting algorithms based on comparison I guess. 2x2 List Quicksortw anyone?
542
N.A.N.Y. 2013 / Re: N.A.N.Y. 2013 Pledge & Release: 2x2 List Sorter
« Last post by Jibz on December 05, 2012, 01:44 AM »
I wonder if randomizing the order of choices would be more confusing or not to the user. It seems like it could maybe improve the expected runtime -- but I am on my first cup of coffee, so I may be wrong :-[.

Nice idea :Thmbsup:.
543
N.A.N.Y. 2013 / Re: NANY 2013 Pledge - Progress Bars of Life
« Last post by Jibz on December 04, 2012, 08:06 AM »
e.g. 15 wks, 5 days, 29 mins, 12 secs to go
i'll have to add some settings for that; perhaps just simply a choice of long and short text modes.

Perhaps allow the user to supply a string compatible with strftime?.
544
N.A.N.Y. 2013 / Re: NANY 2013 Pledge - Progress Bars of Life
« Last post by Jibz on December 03, 2012, 04:45 AM »
If they are all based on time, maybe let the user optionally specify a time formatting string to use instead of the percentage as text on the bar? I mean, so you could make it say "21 days" instead of "94%" on the Christmas bar, or "41 min" instead of "69%" on the Left in Current Hour bar.

The lifespan bar is perhaps a bit ominous? :o

Not if mouser is making it possible to repeat it.  ;)
;D
545
N.A.N.Y. 2013 / Re: NANY 2013 Pledge - Progress Bars of Life
« Last post by Jibz on December 03, 2012, 04:14 AM »
Nice :Thmbsup:

The lifespan bar is perhaps a bit ominous? :o

Also, there is perhaps some ambiguity in percentages "until" something -- like the Until Christmas bar, if there is 94% until Christmas doesn't that sound more like only 6% of the time has passed so far?

546
Developer's Corner / Re: Why C++ Is Not “Back”
« Last post by Jibz on December 02, 2012, 03:43 PM »
Languages like D, Go, and Rust are often mentioned in the context of systems programming languages.
547
N.A.N.Y. 2013 / Re: NANY 2013: Please post requests!
« Last post by Jibz on December 02, 2012, 02:05 PM »
A project idea for someone; anyone! I'm not a coder, though I might get a batch file to work, maybe. Anyway, the idea:   how about a front end or package wrapper that would allow a user to take a program that doesn't normally start with Windows and wrap it in a shell that would allow a user to specify that the program should in fact run with windows.

Is it not still possibly to simply put a link to the program in the Start folder to have it start with Windows?
548
What are your thoughts on the promoted reader comment:

2. Even if your primary concern is piratical, the "darknet" only saves you as long as vendors are willing to ignore legacy formats. All it takes is one person to crack the DRM and release the plaintext version; but only if available consumer devices will actually accept plaintext. Your ipad, say, will process an anonymous mp3, or h.264 video, so team Hollywood and the RIAA crowd are out of luck; but how about an unsigned .ipa file? Not happening. Even if it is 100% structurally valid, it needs an apple key, or an enterprise key, or a dev key(that matches the hardware it is running on, since those are limited to a set number of devices). You can strip all the DRM you want, you'll just have some trouble finding hardware to run it on. Windows RT will play the same game with Windows binaries.

That's the real problem. Yeah, it is impossible to make 100% of DRMed endpoints exfiltration-proof. However, your ability to make 95%+ of endpoints increasingly hostile to anything lacking a trusted DRM signature is constrained only by customer hostility, not by any technological barrier...

Are we busy arguing over how bad DRM is while they are pulling the hardware out from under our feet?
549
Developer's Corner / Re: Why C++ Is Not “Back”
« Last post by Jibz on December 02, 2012, 01:50 PM »
I totally agree with the idea that knowing what happens behind the scenes gives you far more potential for writing good code -- though sometimes it can get in the way of quickly writing code that is good enough :-[. I think perhaps C is a better starting point for getting this knowledge though, since it is so much smaller as a language.

I think you are perhaps falling into the trap of defending C++, when the article isn't really attacking C++ (unless you view is that C++ should be used by everybody for everything). The author even repeatedly says he likes C++, and is just trying to point out that the recent interest does not mean that everybody should start using C++.
550
Developer's Corner / Why C++ Is Not “Back”
« Last post by Jibz on December 02, 2012, 03:45 AM »
http://simpleprogram...1/why-c-is-not-back/

C++11 just came out recently and it seems like there is this big resurgence in interest in C++ development.

Now don’t get me wrong.  C++11 is fantastic!  I am in just about 100% agreement with all of the changes that have been made.  C++ has definitely become much easier to use and it has even become more powerful.

There is one thing it didn’t become though—and this is the most important—more simple.

...

My point of this post is not to bash C++ or bash people using C++ or teaching C++, but rather to blunt the message that seems to be being preached by an over eager C++ community.

Everyone is not going to become a C++ developer and they shouldn’t need to be.  While C++ may have the ability to make your program more efficient (in certain scenarios,) it is extremely unlikely to make you more efficient at creating your program (except in some extreme cases.)

So, I am glad C++ got a much needed overhaul, but I don’t think it is going to make a comeback any time soon, and that is a good thing.

I think this post has some very good points, and it reflects some of my thoughts about C++ lately. The recent changes are (largely) good, and C++ can be very elegant and terribly efficient, it is just really really hard to write good C++ code, and unless you need that extra edge on performance, there are many languages that will make your life a lot easier, especially if you are learning to program.
Pages: prev1 ... 17 18 19 20 21 [22] 23 24 25 26 27 ... 46next