| |

VerySource

 Forgot password?
 Register
Search
View: 761|Reply: 3

Use NEW or IOC?

[Copy link]

2

Threads

3

Posts

4.00

Credits

Newbie

Rank: 1

Credits
4.00

 China

Post time: 2020-2-2 10:40:02
| Show all posts |Read mode
My brother is learning SSH racks recently! When I saw others writing, I found that when calling MODEL, some use IOC or some use NEW to instantiate objects! Please also explain the advantages, disadvantages and trade-offs of these two methods in actual projects!
Reply

Use magic Report

0

Threads

2

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-20 20:30:01
| Show all posts
new manages dependencies by the object itself,
IoC is managed by the container, which means that the container actively injects objects.
Which one you choose depends on your application.
Reply

Use magic Report

0

Threads

4

Posts

5.00

Credits

Newbie

Rank: 1

Credits
5.00

 China

Post time: 2020-8-9 12:45:01
| Show all posts
I think it depends on whether your program is interface-oriented programming. If you provide high scalability and flexibility for you, you should use reverse injection, because the parameters of a function are one interface or another interface. transfer.
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 LAN

Post time: 2020-9-1 19:00:01
| Show all posts
I feel more and more about the power of interface-oriented programming
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list