|
Thread Rules 1. This is not a "do my homework for me" thread. If you have specific questions, ask, but don't post an assignment or homework problem and expect an exact solution. 2. No recruiting for your cockamamie projects (you won't replace facebook with 3 dudes you found on the internet and $20) 3. If you can't articulate why a language is bad, don't start slinging shit about it. Just remember that nothing is worse than making CSS IE6 compatible. 4. Use [code] tags to format code blocks. |
On February 09 2017 08:07 Artesimo wrote:Show nested quote +On February 09 2017 07:45 Manit0u wrote:Just compare the code. In your example plenty of things could go wrong. You could go out of transaction scope unexpectedly, you make two commits for a single change operation, etc. Bonus question: What would happen to the original code if no object was fetched from the db?  I'm not entirely sure why they're assigning you such questions. I would personally use a hatchet on anyone trying to push code like that. Yeah, which is why I was asking in here... I am not really sure what exactly the point of the question is. I am pretty sure they are looking for one/two very specific answers but I am just not sure... About the bonus question: I assume since there hasn't been fetched an actual object from the DB, the entity is empty and you would get some kind of error since you are calling a non static function (setName) in a static enviroment?
The point of the question was ensuring if you knew why the databases are transactional and what are the errors that occur if they're used non-transactionally. Sometimes it's the too-obvious answer.
For the bonus I don't believe static has to do with anything here.
|
On February 09 2017 08:12 Blisse wrote:Show nested quote +On February 09 2017 08:07 Artesimo wrote:On February 09 2017 07:45 Manit0u wrote:Just compare the code. In your example plenty of things could go wrong. You could go out of transaction scope unexpectedly, you make two commits for a single change operation, etc. Bonus question: What would happen to the original code if no object was fetched from the db?  I'm not entirely sure why they're assigning you such questions. I would personally use a hatchet on anyone trying to push code like that. Yeah, which is why I was asking in here... I am not really sure what exactly the point of the question is. I am pretty sure they are looking for one/two very specific answers but I am just not sure... About the bonus question: I assume since there hasn't been fetched an actual object from the DB, the entity is empty and you would get some kind of error since you are calling a non static function (setName) in a static enviroment? The point of the question was ensuring if you knew why the databases are transactional and what are the errors that occur if they're used non-transactionally. Sometimes it's the too-obvious answer. For the bonus I don't believe static has to do with anything here.
You can call a static funtcion without an actual entity, and you can call a function that doesn't affect the attributes of an object (like a simple print) even if the variable doesn't contain the object yet.
RandomClass x = null; x.JustPrintsHello();//works x.getSomeAttribute();//doesn't work;
EDIT: I might be wrong though, but I am sure I had the exact error in my code once and that static/dynamic error message was handed to me by glorious netbeans
|
On February 09 2017 08:07 Artesimo wrote:Show nested quote +On February 09 2017 07:45 Manit0u wrote:Just compare the code. In your example plenty of things could go wrong. You could go out of transaction scope unexpectedly, you make two commits for a single change operation, etc. Bonus question: What would happen to the original code if no object was fetched from the db?  I'm not entirely sure why they're assigning you such questions. I would personally use a hatchet on anyone trying to push code like that. Yeah, which is why I was asking in here... I am not really sure what exactly the point of the question is. I am pretty sure they are looking for one/two very specific answers but I am just not sure... About the bonus question: I assume since there hasn't been fetched an actual object from the DB, the entity is empty and you would get some kind of error since you are calling a non static function (setName) in a static enviroment?
What? No. Implementation of data context has three options.
1. Empty entity. You change it, but nothing happens. It is out of sync. More confusing in this case, but it has its uses as an approach. 2. Null is returned, which you seem to cast as Player. In that code example, you'll get null pointer exception. playerA == null. null.setMethod() is an exception. 3. *SQL Exception. You need a catch block then. E.g.
try { data_context.getTransaction().begin() } catch (SqlException e) { // log exception and handle it if you can }
On February 09 2017 08:24 Artesimo wrote:Show nested quote +On February 09 2017 08:12 Blisse wrote:On February 09 2017 08:07 Artesimo wrote:On February 09 2017 07:45 Manit0u wrote:Just compare the code. In your example plenty of things could go wrong. You could go out of transaction scope unexpectedly, you make two commits for a single change operation, etc. Bonus question: What would happen to the original code if no object was fetched from the db?  I'm not entirely sure why they're assigning you such questions. I would personally use a hatchet on anyone trying to push code like that. Yeah, which is why I was asking in here... I am not really sure what exactly the point of the question is. I am pretty sure they are looking for one/two very specific answers but I am just not sure... About the bonus question: I assume since there hasn't been fetched an actual object from the DB, the entity is empty and you would get some kind of error since you are calling a non static function (setName) in a static enviroment? The point of the question was ensuring if you knew why the databases are transactional and what are the errors that occur if they're used non-transactionally. Sometimes it's the too-obvious answer. For the bonus I don't believe static has to do with anything here. You can call a static funtcion without an actual entity, and you can call a function that doesn't affect the attributes of an object (like a simple print) even if the variable doesn't contain the object yet. RandomClass x = null; x.JustPrintsHello();//works x.getSomeAttribute();//doesn't work;
EDIT: I might be wrong though, but I am sure I had the exact error in my code once and that static/dynamic error message was handed to me by glorious netbeans
That's not correct. If your object is null, it points to nothing. If you have nothing, you cannot expect something. So, calling anything on 'x' is null reference exception (access violation in C/C++).
|
On February 09 2017 08:30 Shield wrote:What? No. Implementation of data context has three options. 1. Empty entity. You change it, but nothing happens. It is out of sync. More confusing in this case, but it has its uses as an approach. 2. Null is returned, which you seem to cast as Player. In that code example, you'll get null pointer exception. playerA == null. null.setMethod() is an exception. 3. *SQL Exception. You need a catch block then. E.g. try { data_context.getTransaction().begin() } catch (SqlException e) { // log exception and handle it if you can }
Yeah, I remember now. You had to burry the uninitialized variable that contained in a class within the function of another class or something like that to make it work. But there surely was a way to achieve described behaviour since I went on to reproduce it with C++ as well out of curiousity.
|
On February 09 2017 08:38 Artesimo wrote:Show nested quote +On February 09 2017 08:30 Shield wrote:What? No. Implementation of data context has three options. 1. Empty entity. You change it, but nothing happens. It is out of sync. More confusing in this case, but it has its uses as an approach. 2. Null is returned, which you seem to cast as Player. In that code example, you'll get null pointer exception. playerA == null. null.setMethod() is an exception. 3. *SQL Exception. You need a catch block then. E.g. try { data_context.getTransaction().begin() } catch (SqlException e) { // log exception and handle it if you can }
Yeah, I remember now. You had to burry the uninitialized variable that contained in a class within the function of another class or something like that to make it work. But there surely was a way to achieve described behaviour since I went on to reproduce it with C++ as well out of curiousity.
You don't have to have another method. I suppose you mean:
Player player = null;
try { player = data_context.find(arg1, arg2); return player; } catch (SqlException e) { // we get an exception from database or data context, so it's likely that player == null // so options are: // 1. return new Player(); // 2. return null; (more obvious than return player object) // 3. throw new YourException(e); // Numbers match the three options I've described in my previous post, // but it's good to log exception anyway. // There are a lot of ways to handle this... You can also rethrow exception. }
|
On February 09 2017 08:47 Shield wrote:You don't have to have another method. I suppose you mean: Player player = null;
try { player = data_context.find(arg1, arg2); return player; } catch (SqlException e) { // we get an exception from database or data context, so it's likely that player == null // so options are: // 1. return new Player(); // 2. return null; (more obvious than return player object) // 3. throw new YourException(e); // Numbers match the three options I've described in my previous post, // but it's good to log exception anyway. // There are a lot of ways to handle this... You can also rethrow exception. }
No, my annecdote I based it on didn't had any to do with SQL/Databases. It was some universityproject, I believe something about distributed systems. Not sure anymore. However, I had class A with a array of generated entities of class B or something like that, only that I failed to generate the classes but everything worked fine, even though methods of those classes where called. Only after I used a method which acceced the attribute of said entity of class B, the programm crashed and it took me a bit to spot my mistake, since it had run fine up to that point. I also believe the reason the other methods where callable was the way methods are stored/accessed, I aksed the prof and he explained it. Forogt everything though so yeah. But thanks for the help, I assume it was about transaction/transactionscope indeed, seems to fit the generel theme of the questions up to this point. Appreciated the help
|
Hmm, I'm not sure I understand, but it sounds like it might involve inheritance and virtual methods. Virtual methods are evaluated at run-time. It's hard to say without code.
|
Non virtual functions are compiled into regular function calls with the this pointer passed in a register. It won't fault unless you dereference it. In any case, that's undefined behavior and implementation specific.
|
On February 09 2017 08:24 Artesimo wrote:Show nested quote +On February 09 2017 08:12 Blisse wrote:On February 09 2017 08:07 Artesimo wrote:On February 09 2017 07:45 Manit0u wrote:Just compare the code. In your example plenty of things could go wrong. You could go out of transaction scope unexpectedly, you make two commits for a single change operation, etc. Bonus question: What would happen to the original code if no object was fetched from the db?  I'm not entirely sure why they're assigning you such questions. I would personally use a hatchet on anyone trying to push code like that. Yeah, which is why I was asking in here... I am not really sure what exactly the point of the question is. I am pretty sure they are looking for one/two very specific answers but I am just not sure... About the bonus question: I assume since there hasn't been fetched an actual object from the DB, the entity is empty and you would get some kind of error since you are calling a non static function (setName) in a static enviroment? The point of the question was ensuring if you knew why the databases are transactional and what are the errors that occur if they're used non-transactionally. Sometimes it's the too-obvious answer. For the bonus I don't believe static has to do with anything here. You can call a static funtcion without an actual entity, and you can call a function that doesn't affect the attributes of an object (like a simple print) even if the variable doesn't contain the object yet. RandomClass x = null; x.JustPrintsHello();//works x.getSomeAttribute();//doesn't work;
EDIT: I might be wrong though, but I am sure I had the exact error in my code once and that static/dynamic error message was handed to me by glorious netbeans
I meant it more in the sense that it wasn't a static method so bringing static-ness into it doesn't really apply. It'd be simply an error because either the object is null, or the object was fetched but out-of-sync, or however that database handles that situation as Shield described.
I've never seen people call a static method thruogh a null object before ... but I just tested it in Java and it works. freaky af, please don't do that purposely irl lol.
Object a = null; a.staticMethod(); // worked normally
|
anyone wanna tutor me in linear algebra for $15/hr ? it's confusing the shit out of me and my professor is terrible
it'd be casual, over skype or w/e, whatever hours work, maybe a couple of hours a week
im honestly finding it was more confusing than calc 1 or calc 2 but I think it's largely because the teaching of it is so convoluted...
note: math at my school is pretty tough
|
|
I'll go through them, thank you 
wow that first video has a nice like ratio
|
On February 09 2017 10:31 Blisse wrote:Show nested quote +On February 09 2017 08:24 Artesimo wrote:On February 09 2017 08:12 Blisse wrote:On February 09 2017 08:07 Artesimo wrote:On February 09 2017 07:45 Manit0u wrote:Just compare the code. In your example plenty of things could go wrong. You could go out of transaction scope unexpectedly, you make two commits for a single change operation, etc. Bonus question: What would happen to the original code if no object was fetched from the db?  I'm not entirely sure why they're assigning you such questions. I would personally use a hatchet on anyone trying to push code like that. Yeah, which is why I was asking in here... I am not really sure what exactly the point of the question is. I am pretty sure they are looking for one/two very specific answers but I am just not sure... About the bonus question: I assume since there hasn't been fetched an actual object from the DB, the entity is empty and you would get some kind of error since you are calling a non static function (setName) in a static enviroment? The point of the question was ensuring if you knew why the databases are transactional and what are the errors that occur if they're used non-transactionally. Sometimes it's the too-obvious answer. For the bonus I don't believe static has to do with anything here. You can call a static funtcion without an actual entity, and you can call a function that doesn't affect the attributes of an object (like a simple print) even if the variable doesn't contain the object yet. RandomClass x = null; x.JustPrintsHello();//works x.getSomeAttribute();//doesn't work;
EDIT: I might be wrong though, but I am sure I had the exact error in my code once and that static/dynamic error message was handed to me by glorious netbeans I meant it more in the sense that it wasn't a static method so bringing static-ness into it doesn't really apply. It'd be simply an error because either the object is null, or the object was fetched but out-of-sync, or however that database handles that situation as Shield described. I've never seen people call a static method thruogh a null object before ... but I just tested it in Java and it works. freaky af, please don't do that purposely irl lol. Object a = null; a.staticMethod(); // worked normally
I suppose it works because it is translated into Class.staticMethod() rather than a.staticMethod(). It's weird when 'a' object is null.
|
On February 09 2017 16:28 Shield wrote:Show nested quote +On February 09 2017 10:31 Blisse wrote:On February 09 2017 08:24 Artesimo wrote:On February 09 2017 08:12 Blisse wrote:On February 09 2017 08:07 Artesimo wrote:On February 09 2017 07:45 Manit0u wrote:Just compare the code. In your example plenty of things could go wrong. You could go out of transaction scope unexpectedly, you make two commits for a single change operation, etc. Bonus question: What would happen to the original code if no object was fetched from the db?  I'm not entirely sure why they're assigning you such questions. I would personally use a hatchet on anyone trying to push code like that. Yeah, which is why I was asking in here... I am not really sure what exactly the point of the question is. I am pretty sure they are looking for one/two very specific answers but I am just not sure... About the bonus question: I assume since there hasn't been fetched an actual object from the DB, the entity is empty and you would get some kind of error since you are calling a non static function (setName) in a static enviroment? The point of the question was ensuring if you knew why the databases are transactional and what are the errors that occur if they're used non-transactionally. Sometimes it's the too-obvious answer. For the bonus I don't believe static has to do with anything here. You can call a static funtcion without an actual entity, and you can call a function that doesn't affect the attributes of an object (like a simple print) even if the variable doesn't contain the object yet. RandomClass x = null; x.JustPrintsHello();//works x.getSomeAttribute();//doesn't work;
EDIT: I might be wrong though, but I am sure I had the exact error in my code once and that static/dynamic error message was handed to me by glorious netbeans I meant it more in the sense that it wasn't a static method so bringing static-ness into it doesn't really apply. It'd be simply an error because either the object is null, or the object was fetched but out-of-sync, or however that database handles that situation as Shield described. I've never seen people call a static method thruogh a null object before ... but I just tested it in Java and it works. freaky af, please don't do that purposely irl lol. Object a = null; a.staticMethod(); // worked normally
I suppose it works because it is translated into Class.staticMethod() rather than a.staticMethod(). It's weird when 'a' object is null.
But, shouldn't you call static methods with :: instead of .?
|
On February 09 2017 02:38 mantequilla wrote:do you guys have an idea what kind of technical knowledge is required to work in defense industry as a programmer? I assume they are not writing web apps with angular  disclaimer: I don't know c or c++.
quoting myself from a few pages back since no one noticed me
|
|
On February 09 2017 17:43 mantequilla wrote:Show nested quote +On February 09 2017 02:38 mantequilla wrote:do you guys have an idea what kind of technical knowledge is required to work in defense industry as a programmer? I assume they are not writing web apps with angular  disclaimer: I don't know c or c++. quoting myself from a few pages back since no one noticed me 
Shield noticed you:
On February 09 2017 03:36 Shield wrote:Show nested quote +On February 09 2017 02:38 mantequilla wrote:do you guys have an idea what kind of technical knowledge is required to work in defense industry as a programmer? I assume they are not writing web apps with angular  disclaimer: I don't know c or c++. I don't know about your question, but just a reminder that you might need security clearance for that thing. Edit: I also remember hearing about MISRA, but I don't know how widely used it is.
|
Next DB question, regarding the n+1 problem with default fetching:
A JPA-query fetches a list of all books of publishers with a specific location.
Tables/Columns: Publisher(PublisherID[primaryKey], name, location)) Book(ISBN[primaryKey], titel, price, publisherID[foreignKey])
About 700 publishers, 40 of them in the specific location, each of which has about 200 books in its inventory.
Question: Explain the n+1 problem, regarding the 40 publishers. How many selects willbe send to the database?
Answer: We got 41 selects that are send to the database. 1 select to get all the publishers of the specific location(40) and for each publisher we have a select to get all published books, therefore we got another 40 selects.
And another regarding the difference of data I get from a fetch join / join in an application: Join will give back a single entity per member/facutly combination, like all members of a faculty while fetch join would give me 2 entities per member/facutly combination: the member and the faculty seperately
|
My company wants to replace all ~1500 PCs across all stores so they can access the coming web frontend since the old XP/IE8 boxes can't do HTML5 and stuff and so wont Work with the Hybris shop that is in the works.
I was just thinking about using thin clients that just use remote desktop or something like that instead. What solutions would work for 1500 PCs across all of europe without requiring the same amount of physical hardware? Maybe stuff that works decently with not-that-modern Internet connections as well?
I'm a programmer, not an admin, so it's not really my field of expertise.
|
On February 09 2017 23:45 Morfildur wrote: My company wants to replace all ~1500 PCs across all stores so they can access the coming web frontend since the old XP/IE8 boxes can't do HTML5 and stuff and so wont Work with the Hybris shop that is in the works.
I was just thinking about using thin clients that just use remote desktop or something like that instead. What solutions would work for 1500 PCs across all of europe without requiring the same amount of physical hardware? Maybe stuff that works decently with not-that-modern Internet connections as well?
I'm a programmer, not an admin, so it's not really my field of expertise. If it is going to run over the internet use cheap laptops (or desktops) with linux and firefox or something like that. This shit is so cheap nowadays that the price shouldnt even matter for a company big enough to have 1500 workstations. Thats what I would do anyways.
|
|
|
|