AdaHacker's Profile User Rating: -----

Reputation: 463 Architect
Active Members
Active Posts:
820 (0.28 per day)
17-June 08
Profile Views:
Last Active:
User is offline Mar 11 2016 07:13 AM

Previous Fields

OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:

Latest Visitors

Icon   AdaHacker has not set their status

Posts I've Made

  1. In Topic: MySQL - PHP - Unity

    Posted 25 Jun 2015

    View PostAsthenia, on 25 June 2015 - 09:36 AM, said:

    Do I need to save it as an array then encapsulate it in JSON_Encode()

    Well, you don't have to do that. It's just one of the easier ways to do it. :)

    But yes, that's the basic idea. So you might do something like the following totally untested sample code:
    // Connect to the database 
    $pdo = new PDO('some connection string');
    // Run your query
    $stmt = $pdo->prepare('select * from whatever where something = ?');
    // Get a result
    $result = $stmt->fetch(PDO::FETCH_ASSOC);
    // Package that up in a known format.  
    // Alternatively, since the result is an associative array, 
    // you could just use that directly.
    $data = array(
        'AdmobID' => $result['Admob_ID'],
        'OtherThing' => $result['something_else']
    // Convert that array to JSON and output it
    echo json_encode($data);

    That would output something like {"Admob ID":"12343214321","OtherThing":"some other thing"}, which any reasonable JSON parser should be able to deal with.

    One other thing to note is that you used the function mysql_result, which is part of the old MySQL extension. That extension is deprecated and should not be used in new code. You might want to look into using MySQLi or PDO instead.
  2. In Topic: MySQL - PHP - Unity

    Posted 24 Jun 2015

    View PostCTphpnwb, on 24 June 2015 - 12:53 PM, said:

    Why do you want to use C#?

    He's talking about the Unity code. Unity is a 3D gaming engine built on Mono and so uses C# as its primary "scripting" language. It sounds like the OP's problem is understanding how to get the text data returned from an HTTP request into his strongly typed C# objects.

    View PostAsthenia, on 24 June 2015 - 11:26 AM, said:

    My original idea was I need to run a WWW call, which would then return back to me the query results as just a page of string, which I could then deserialise into a class object so I could store my results into c# variables.

    Yeah, that's basically it. Your response from the web server is going to be essentially one big string and you'll need to parse that in your C# code, do any type conversion you need, and save the values into whatever objects are appropriate.

    On the up side, that's not actually as difficult as it might sound. Since you control the format of the data the server is sending out, you can just pick a format that's easy for you to parse. For example, in the Unity project I'm working on, we just return all the data from the server as a JSON string. That's easily done in PHP by creating an array in whatever format is appropriate and then running it through json_encode(). We then use SimpleJSON to parse that into an object that we can use in C#. Once you have that SimpleJSON object, getting the appropriate bits of data to update your C# objects is fairly easy - it even has convenience properties for getting values as specific data types.
  3. In Topic: Why is there no boolean datatype in MySQL?

    Posted 14 May 2015

    Take a look at the documentation for the BIT type. It's for storing bit fields, not individual bits. It even has a funky specialized syntax for expressing bit literals. So if all you want to do is store a simple true/false flag, a BIT type is probably a bad choice. As e_i_pi said, just stick with TINYINT(1).
  4. In Topic: Formal Verification of Programs

    Posted 20 Mar 2015

    View PostBetsemes, on 20 March 2015 - 11:16 AM, said:

    It's actually a question asking for you to clarify what did you mean by "formal modeling languages" and "code-level verification". The myth was your assumption on what motivated my question.
    On rereading my post, I realize this may sound rude. Sorry if it does. I meant no offense.

    No offense taken. Sorry I misunderstood what you were asking. I just meant that I looked at methods and notations that dealt more with higher-level abstractions, such as modeling the overall design of a system, as opposed to techniques for verifying implementations at the code level. So more things like applying VDM or Z to system specifications as opposed to analyzing source code. Nothing terribly deep - I probably could have phrased it better.

    View PostBetsemes, on 19 March 2015 - 12:34 PM, said:

    This apparently says that VDM can model a system at a higher level and then drop to code level verification. Is this true? Can VDM be used on all levels? Am I misreading it?

    Your understanding is correct. I don't claim to be an expert on VDM, and I didn't get too deep into the refinement part of it, but it does include methods for refining your models from higher to lower level. And yes, you can go all the way down to the code level if you really want to. Of course, as Skydiver was getting at, the semantics of a low-level VDM specification will not necessarily map to your implementation language, so you'd just be verifying the logic of your program, not the actual implementation. But depending on your goals, that's not necessarily a problem.

    View PostBetsemes, on 19 March 2015 - 12:34 PM, said:

    EDIT: Or maybe, if the model have been proven correct, we can generate correct code without verification? True? False?

    If you have a sufficiently detailed model, this is theoretically possible. At the lowest level, an explicit VDM specification is essentially equivalent to source code. And there are "model animators" that will allow you to "execute" a specification like a program. I seem to recall that Overture could do model animation, though it was limited to explicit specifications. It's been a while, though, so I'm not certain.

    As far as actually generating code from a specification, I've only read about it. I have no experience with it so I don't know if there are any tools available to do it or what their quality is.

    View PostBetsemes, on 19 March 2015 - 12:34 PM, said:

    I chose C++ for this and I was looking around for a formal method that can enable me to enter a less buggy beta testing stage. I think I can achieve this with VDM++. Is this true?

    Maybe. Using formalism can help you to think more rigorously about the program you're building and give you another tool to analyze it. This can help you verify that your program covers all your requirements, that you haven't missed things in the design, that your logic is correct, etc. My own experience, and what I've read in case studies, is that they can help you find bugs before you've written them in the implementation language. But as I said in a previous post, formalism is just another tool and how much value you get out of it will depend on how you use it. If this is your first project with VDM++, it might be useful, but because the learning curve is steep you shouldn't expect huge quality improvements right away.

    View PostBetsemes, on 19 March 2015 - 12:34 PM, said:

    Maybe VDM-SL is well suited for such a project. Is it?

    I don't know. It really depends on what you're trying to accomplish. Actual execution speed is more of a low-level, implementation-dependent thing, so I wouldn't necessarily expect a notation like VDM-SL to be too helpful in analyzing that (though to be honest, I haven't looked into that at all). Now if you wanted to use VDM to model different implementations and make sure that they're still behaving correctly, that's a different story. I can see VDM working well for something like that.

    View PostBetsemes, on 19 March 2015 - 12:34 PM, said:

    Is there a drawback on using formal methods for developing those two projects, other than the learning time I have to take?

    Well, it really all comes down to time.

    First, there's the learning curve. For most formal methods, it's pretty steep, even if you already have the mathematical background for them. In addition to the notation, it's kind of a different way of thinking. As one article I read put it, writing formal specifications is a different skill set than writing code. It's a new way of doing things that you'll have to integrate into your development process.

    Second, there's the time spent actually working with the formalism. Experienced formal methods practitioners do the formal analysis and get the project done in the same or less time than without it, because the extra up-front analysis translates to fewer issues during implementation. However, if you're not experienced, this may not be the case. The formalization will probably take you longer; you may find holes or errors in your analysis and have to revisit it later in the development cycle; you may do too much formalization and end up doing a lot of analysis that just isn't that useful.

    In any event, I expect the only thing you stand to lose is time. If you're not experienced, then it's debatable how much using VDM will increase the quality of your software, but I doubt it would make it any worse. The only risk is that you end up taking more time than you'd like to complete the project. Just make sure your expectations are reasonable. If you're looking for immediate results on these projects, you may be disappointed. I would look at these projects more as "pilot programs" to help you learn VDM so you can use it to better effect in the future. That's one of the big lessons from the literature - learning formal methods is a long-term investment.
  5. In Topic: [PHPUnit] organise large test set

    Posted 19 Mar 2015

    As a rule of thumb, you can apply the same organizational principles to test code that you do to your application code. It may be a common pattern, but there's no law that says you have to have exactly one test class per application class. If the test class is getting too unwieldy, then by all means go ahead and break it up. You could also do one test class per method, or one for each logical feature, or something else entirely - whatever makes the most sense for your case. The exact scheme you use isn't that critical so long as the organization is consistent and it's easy to figure out where a particular test would be located.

    However, you can also look at it from the other direction. Maybe the huge test class is an indication of other problems. Does the class under test really need to be that big? Maybe the solution is to refactor your application class into multiple smaller classes, in which case the test organization would take care of itself. (Not that I know one way or the other - I'm just playing devil's advocate here.)

My Information

Member Title:
Resident Curmudgeon
38 years old
August 16, 1977
Brockport, NY
On the technical front, I'm interested in software design methods, formal modeling, database theory, etc.. In more general terms, I like to play the piano, study philosophy, and work in my garden.
Years Programming:
Programming Languages:
PHP, Python, JavaScript, C#, SQL, and whatever other stuff I've worked with that I feel like including today.

Contact Information

Website URL:
Website URL



Page 1 of 1
  1. Photo

    AdaHacker Icon

    09 Feb 2011 - 15:18
    <shrug> Never really had anything to ask. I prefer to just take a quick browse through my favorite forums once in a while and provide a few quick answers. Less of a time commitment.
  2. Photo

    modi123_1 Icon

    09 Feb 2011 - 13:39
    Odd.. you are a member since Jun 2008, have 572 active topics, but have zero posts originated by you. Quirky.
Page 1 of 1