Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Shaggar
Apr 26, 2006
yeah. always use stored procs. and thats not sql server specific, but you should be using sql server.

Adbot
ADBOT LOVES YOU

Notorious b.s.d.
Jan 25, 2003

by Reene

St Evan Echoes posted:

shaggar did I read you saying it's better to set up all your queries on sql server as stored procedures and then just exec from your app?

statement mapping is the same idea but on the client side. you pre-write all of your queries and stuff them in objects, then call them with parameters. if you set it up right, you get sane return values back instead of dumb strings

this has most of the downsides of stored procedures but it becomes much easier to do version control

Notorious b.s.d.
Jan 25, 2003

by Reene

Shaggar posted:

yeah. always use stored procs. and thats not sql server specific, but you should be using sql server.

lol

Shaggar
Apr 26, 2006
stored procs don't have downsides, only upsides. if you're using orms its cause your data doesn't matter

Notorious b.s.d.
Jan 25, 2003

by Reene
per-app views and stored procedures are pretty great if you have lots of apps talking to the same database and you work in enterprise java hell

for the rest of us, where often a single app uses the DB, there's no reason to put up with the hassle and lovely version control

Shaggar
Apr 26, 2006
if you have more than 1 application touching your db, not using procs is a recipe for disaster.

Notorious b.s.d.
Jan 25, 2003

by Reene

Shaggar posted:

if you have more than 1 application touching your db, not using procs is a recipe for disaster.

i agree completely

but i don't plan apps around that idea. i don't work in an environment where that is likely to come to pass. serialising to sql gives me an "out" if i need one later, it's not super important in the here and now.

distortion park
Apr 25, 2011


Shaggar posted:

all logic belongs in the controller. if you have logic in the model then it can have effects on the controller and view and you don't want that. you want the model to just be dumb data that you pass around. it can have metadata (annotations/attributes) for validation and stuff, but not logic.

code that retrieves the model from the database is an extension of the controller, not the model.

Do not loving use orms ever. do not use entity framework outside of statement mapping (which it still doesn't do great)

microsoft mvc tutorial disagrees

quote:

Models. Model objects are the parts of the application that implement the logic for the application s data domain. Often, model objects retrieve and store model state in a database. For example, a Product object might retrieve information from a database, operate on it, and then write updated information back to a Products table in SQL Server.

quote:

Controllers. Controllers are the components that handle user interaction, work with the model, and ultimately select a view to render that displays UI. In an MVC application, the view only displays information; the controller handles and responds to user input and interaction. For example, the controller handles query-string values, and passes these values to the model, which in turn queries the database by using the values.

i might be misunderstanding though

Cybernetic Vermin
Apr 18, 2005

it would be nice if databases really were flexible enough that you could throw whatever at them and believe that it would work out, but it just isn't the case; whether sprocs is good design (and release practice) is debatable, but that they are the safe and efficient way to go is not

Shaggar
Apr 26, 2006
they're talking about using entity framework as an orm (don't ever do this) in which case all your objects inherit from entity or whatever so they have these methods for saving themselves and updating themselves. its all very gross, but technically the logic is still outside the model its just called from the base methods of Entity. (iirc)

in all of their examples the actual logic of what to get from the database is done in the controller and then ef generates the sql to do the work. Since ef is outside the model and the logic it uses to generate the sql comes from your code in the controller I would consider it part of the controller, not the model.

Shaggar
Apr 26, 2006

Cybernetic Vermin posted:

it would be nice if databases really were flexible enough that you could throw whatever at them and believe that it would work out, but it just isn't the case; whether sprocs is good design (and release practice) is debatable, but that they are the safe and efficient way to go is not

I don't think you know what a stored proc is. they're far more efficient and far safer than direct queries. direct queries are the least safe and least efficient possible way to access data from an application.

Notorious b.s.d.
Jan 25, 2003

by Reene

pointsofdata posted:

microsoft mvc tutorial disagrees

i might be misunderstanding though

traditionally, your business logic goes in the model. shaggar asserts that you should defy tradition and adapt mvc to the needs of enterprise software development

Notorious b.s.d.
Jan 25, 2003

by Reene

Shaggar posted:

I don't think you know what a stored proc is. they're far more efficient and far safer than direct queries. direct queries are the least safe and least efficient possible way to access data from an application.

i'll get right back to you as soon as i start prioritizing safety or efficiency over development time or readability

Shaggar
Apr 26, 2006
safety and efficiency are important to data integrity which is how your business makes money.

Shaggar
Apr 26, 2006

Notorious b.s.d. posted:

traditionally, your business logic goes in the model. shaggar asserts that you should defy tradition and adapt mvc to the needs of enterprise software development

i've only ever seen business logic in the model of bad applications

Cybernetic Vermin
Apr 18, 2005

Shaggar posted:

I don't think you know what a stored proc is. they're far more efficient and far safer than direct queries. direct queries are the least safe and least efficient possible way to access data from an application.

i am perplexed how you managed to misread that post quite this badly

Shaggar
Apr 26, 2006
oh I thought you were saying they were not safe and efficient. ok.

Notorious b.s.d.
Jan 25, 2003

by Reene

Shaggar posted:

safety and efficiency are important to data integrity which is how your business makes money.

in a database accessed by a single application, stored procs have no impact on data integrity

efficiency almost never matters to anyone, ever. they say it matters, but in reality they'd rather have the application on time

Shaggar
Apr 26, 2006
stored procs really aren't much of a development cost when compared to the amount of garbage you have to do w/ an orm.

Shaggar
Apr 26, 2006
especially entity framework. god that thing is bad.

jony ive aces
Jun 14, 2012

designer of the lomarf car


Buglord

Shaggar posted:

With MVC anything is possible if it is possible within the realm of web.
is zombo made with asp mvc

jony ive aces
Jun 14, 2012

designer of the lomarf car


Buglord

A COMPUTER GUY posted:

no fat models
           \

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
i have a single app touching multiple DBs...what sort of procs should i be using for that?

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

USSMICHELLEBACHMAN posted:

i have a single app touching multiple DBs...what sort of procs should i be using for that?

multiple databases on the same database server, or are they all over the place? i know you can do cross-db stuff in sql server if they're both hosted on the same server instance (terminology may be incorrect)

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
same server. one is mongoDB and the other is pgSQL

prefect
Sep 11, 2001

No one, Woodhouse.
No one.




Dead Man’s Band

USSMICHELLEBACHMAN posted:

same server. one is mongoDB and the other is pgSQL

okay, different db engines. can you even have stored procedures in mongo?

DONT THREAD ON ME
Oct 1, 2002

by Nyc_Tattoo
Floss Finder
that's a good question. i dont really know

EAT THE EGGS RICOLA
May 29, 2008

It probably works, I say just go for it.

Notorious b.s.d.
Jan 25, 2003

by Reene
if they had both been sql server, a single query/sp could have touched both databases :smug:

Socracheese
Oct 20, 2008

mongodb sucks and i will bet if you trace its origins in your workplace it will lead you to someone with a very punchable face

(its u)

Socracheese
Oct 20, 2008

hey CODERS

-yeah?

are your sql db queries SLOW?

-no, not really.

Yeah? Then you should try MongoDB its totally radical and saves multiple copies of ur data and-

-shut up go away

MeruFM
Jul 27, 2010
just put all your raw queries in a single file/folder/object/whatever and don't use ORMs.
code:
Include/Import MongoEngine
Include/Import SQL

SuperSpecialQuery1{
    mangoStuff = MongoEngine crap
    sqlStuff = SQL query
    return mangoStuff + sqlStuff;
}
I don't understand who thought ORMs were a good idea, what do they accomplish other than run horrible mashup sql. otoh, another team executes raw hql so

Shaggar
Apr 26, 2006

USSMICHELLEBACHMAN posted:

i have a single app touching multiple DBs...what sort of procs should i be using for that?

whatever procedure replaces them w/ a single sql server

Blinkz0rz
May 27, 2001

MY CONTEMPT FOR MY OWN EMPLOYEES IS ONLY MATCHED BY MY LOVE FOR TOM BRADY'S SWEATY MAGA BALLS

Shaggar posted:

they're talking about using entity framework as an orm (don't ever do this) in which case all your objects inherit from entity or whatever so they have these methods for saving themselves and updating themselves. its all very gross, but technically the logic is still outside the model its just called from the base methods of Entity. (iirc)

in all of their examples the actual logic of what to get from the database is done in the controller and then ef generates the sql to do the work. Since ef is outside the model and the logic it uses to generate the sql comes from your code in the controller I would consider it part of the controller, not the model.

Blinkz0rz posted:

fat dtos between skinny models and skinny viewmodels

ProSlayer
Aug 11, 2008

Hi friend

USSMICHELLEBACHMAN posted:

i have a single app touching multiple DBs...what sort of procs should i be using for that?

Setup linked servers.

emoji
Jun 4, 2004
lol if your application doesn't use use oracle, teradata, hive/hadoop, and multiple local databases just for caching. lol if you don't have teams of data janitors QAing and normalizing everything so the data you consume is like 3 layers removed from raw

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

Notorious b.s.d. posted:

per-app views and stored procedures are pretty great if you have lots of apps talking to the same database and you work in enterprise java hell

for the rest of us, where often a single app uses the DB, there's no reason to put up with the hassle and lovely version control

lmao gtfo bsd orms suck for many many reasons

if u dont give a poo poo about your data, use an orm

Malcolm XML
Aug 8, 2009

I always knew it would end like this.

kraftwerk singles posted:

lol if your application doesn't use use oracle, teradata, hive/hadoop, and multiple local databases just for caching. lol if you don't have teams of data janitors QAing and normalizing everything so the data you consume is like 3 layers removed from raw

double sulk
Jul 2, 2010

https://gist.github.com/munificent/9749671

you'll know it when you see it

Adbot
ADBOT LOVES YOU

Morkai
May 2, 2004

aaag babbys
i don't understand this:

Malcolm XML posted:

if u dont give a poo poo about your data, use an orm

how does using an orm negatively impact data integrity? maybe you're just doing poo poo wrong (or have only seen it done wrong) and making snap judgements about it?

  • Locked thread